Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision Both sides next revision
apache:redirect-non-www-to-www [2011-07-01 19:19:34]
garrett.plasky Approved
apache:redirect-non-www-to-www [2014-08-06 01:12:47]
shaun.reitan
Line 3: Line 3:
 This is an example using the mod_rewrite Apache module to force all traffic to your site to www.yourodmain.com. This can be useful in an SSL context, as well as for SEO purposes. Create a .htaccess file in your webroot (public_html for cPanel servers) and add the following lines: This is an example using the mod_rewrite Apache module to force all traffic to your site to www.yourodmain.com. This can be useful in an SSL context, as well as for SEO purposes. Create a .htaccess file in your webroot (public_html for cPanel servers) and add the following lines:
  
-<sxh apache>RewriteEngine On+<sxh>RewriteEngine On
 RewriteCond %{HTTP_HOST} ^your-domain.com RewriteCond %{HTTP_HOST} ^your-domain.com
-RewriteRule (.*) http://www.your-domain.com/$1 [R=301,L]</sxh>+RewriteRule (.*) http://www.your-domain.com/$1 [R=301,L] 
 +</sxh>
  
 {{tag>apache how-to}} {{tag>apache how-to}}