Here’s a rather wonderful mod_rewrite script that makes your website very google friendly. It will take any Request_URI and concatenate www. to its start. Search engines such as google love this consistency. This is why some of my articles feature on page 1 of google’s search results, often very quickly after being published.
Here’s the script which you should put in either your vhost configuration file or docroot .htaccess file
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule .* http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
Thanks to RichardK, resident mod_rewrite consultant at the mod_rewrite forums.
December 9, 2006



















Horaayy..there are 2 comment(s) for me so far ;)
Thanks for this. Can’t seem to get it working though. Is there any specific setting you could point this down to and in what file (this is for an apache server)?
Hi,
As the article notes, you should put this in your .htaccess file or within your vhost httpd configuration. I, personally, put these in my vhost configuration (well, i tell a lie - this site uses Zeus ZXTM for URL re-writes across my Apache cluster) as requiring httpd to read *every* document directory for every request is hugely inefficient. My advice is to put this within your vhost file. Please contact your OS vendor for assistance with this if you require httpd help.
All the best,
Chris