Force www on all your domains

A generic piece of code you can drop in all of your .htaccess files to force "www." no matter what the domain name is.

I like to have all my websites set up with "www." to avoid SEO and cookie issues (when using the FEU module to allow user logins).

The code below will work on any domain name so it's really easy to include it in your "default" .htaccess.

<IfModule mod_rewrite.c>
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

ps: don't forget to disable this when working on your localhost or testing cmsms setups trough the server IP!

Below you will find the generic code to remove the www on any domain:

<IfModule mod_rewrite.c>
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]