Redirecting All Web Requests to the WWW. DNS Entry for Your Web Site

If you would like to redirect all non ‘www’ requests for pages on your site to the ‘www’ dns entry add the following to your .htaccess file in the document root of your site:

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

Leave a Reply