301 non-www to www Redirect

301 non-www to www Redirect

Here is how to direct your website to have www. prefix your domain even if someone does not type it in the address bar with www.

<code>

RewriteEngine On

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

</code>

The ‘(*.)$’ says that we’ll take anything that comes after http://seobook.com and append it to the end of ‘http://www.kdmconsultants.com’ (thats the ‘$1’ part) and redirect to that URL. For more grit on how this works checkout a good regular expressions resource or two.

Note: You only have to enter ‘RewriteEngine On’ once at the top of your .htaccess file.Here is how to direct your website to have www. prefix your domain even if someone does not type it in the address bar with www.

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *