Last active
February 6, 2022 09:21
-
-
Save aobasar/7c74df8f40c813d0e656 to your computer and use it in GitHub Desktop.
Non www to www php redirection for IIS6
This file contains hidden or 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 | |
/* Non www to www php redirection for IIS6 */ | |
if (!strpos('|||' . $_SERVER['HTTP_HOST'],"www") && !isset($_REQUEST['rd'])) { | |
$redirect = "http://www.oguzhanbasar.com"; | |
if (isset($_SERVER['REQUEST_URI']) && strlen($_SERVER['REQUEST_URI'])>0) { | |
$redirect .= $_SERVER['REQUEST_URI']; | |
} | |
if (strpos($redirect,"?")) { | |
//$redirect .= "&rd=1"; | |
} else { | |
//$redirect .= "?rd=1"; | |
} | |
header("HTTP/1.1 301 Moved Permanently"); | |
header("Location: " . $redirect); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment