/ Published in: PHP
Issues a check to see if the "www" is included, if not, forces "www" to be appended to the URL in question.
Expand |
Embed | Plain Text
Comments
Subscribe to comments
You need to login to post a comment.

if ( 0 !== stripos( $SERVER['HTTPHOST'], 'www.' ) ) { header( 'HTTP/1.1 301 Moved Permanently' ); header( 'Location: http://www.' . $SERVER['HTTPHOST'] . $SERVER['REQUESTURI'] ); exit; }
Whoops:
if ( 0 !== stripos( $_SERVER['HTTP_HOST'], 'www.' ) ) { header( 'HTTP/1.1 301 Moved Permanently' ); header( 'Location: http://www.' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ); exit; }