Force www on a website

Jun 2nd 2010

If you are running Apache web server and already have an .htaccess file then simply add this:

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


If you are running Apache and do not have a .htaccess file then create one and place the above code in it.

If you still are having problems make sure your Apache config is set to take .htaccess commands.