Created
September 2, 2012 10:09
-
-
Save rolandinsh/3596420 to your computer and use it in GitHub Desktop.
PHP with/without www
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* redirect to with/without www version of page | |
* @date 2012-09-02 | |
*/ | |
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']); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment