Redirect all domains to www version
How to redirect all domains on a server to the www version? For example suppose we wish to redirect http://domain.com to http://www.domain.com, but in addition we wish to do this for ALL domains on one server.
Simply add this to the apache configuration file, usually httpd.conf:
RewriteCond %{HTTP_HOST} !^www [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [L,R=301]
This avoids multiple entries for each domain, and in addition avoids use of .htaccess files which should really be avoided for performance purposes.
