From the mind of Jamie Huskisson: Nottingham freelance UK PHP, Magento, Wordpress developer

Force www. in your URL using .htaccess

Posted on March 15th, 2007 in ,

Insert this into the top of your .htaccess file, making sure that ‘RewriteEngine On’ comes before it:

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

Replace jhuskisson.com with your chosen domain and make sure if you are placing any full stops within the first line to enter a backslash before each full stop. This will prevent the code from not working.

Bookmark and Share

If you enjoyed this post:

Please take the time to leave a comment with any of your thoughts, follow me on Twitter or subscribe to my RSS Feed for automatic updates on all future posts.

There are 9 responses to this post so far

Feel free to use any of the following tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>