Adding www to your domain using 301 redirect with htaccess

You can tell the server to automatically append www on each query to your website using .htaccess. That is all incoming requests to a non www query gets forwarded to the host with www prepended before the domain. Although google treats them equally now, yahoo and live search may not. So its still wise to add them to your website somehow. Its a great advantage to your site especialy in terms of search engine optimization.

Here is the .htaccess script that forwards all request without www to your website having the www before the domain name.


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

Please note that this is only possible to websites that are hosted in either Linux or Unix servers running Apache

Leave a comment

Recent Entries

Close