This code is a 301 redirect from:
http://yoursite.com to
http://www.yoursite.com
[php]<?php
if (!strstr($_SERVER['HTTP_HOST'],'www')){
header('HTTP/1.1 301 Moved Permanently');
header('Location:
http://www.' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
exit();
}
?>[/php]