Menu


How to use mod_rewrite for redirecting www and non www address to same page


From a SEO perspective it is a good idea to redirect your site from a non www address (http://example.com) to the www prefixed version (http://www.example.com).

Here is how can you do that:

You must edit or if you do not have one create the file .htaccess (the leading dot must be included) in the root of your website and place the following code in it:


RewriteEngine On
RewriteCond %{HTTP_HOST} !^www.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L] 





Apache categories


Apache Installation? | Apache Configuration | Apache Troubleshooting?

Back to > Software




Google Search

 
www.lacisoft.com
WWW
2009-2011 (c) Lacisoft.com