Issues a check to see if the "www" is included, if not, forces "www" to be appended to the URL in question.

PHP Code: 
    <?php
    
if (substr($_SERVER['HTTP_HOST'],0,3) != 'www') {
    
header('HTTP/1.1 301 Moved Permanently');
    
header('Location: http://www.'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
    }
    
?>
Kevin Reviewed by Kevin on . SEO - 301 Cononical Redirect - Adds WWW Issues a check to see if the "www" is included, if not, forces "www" to be appended to the URL in question. <?php if (substr($_SERVER,0,3) != 'www') { header('HTTP/1.1 301 Moved Permanently'); header('Location: http://www.'.$_SERVER.$_SERVER); } ?> Rating: 5