Skip to content

Instantly share code, notes, and snippets.

@aobasar
Last active February 6, 2022 09:21
Show Gist options
  • Save aobasar/7c74df8f40c813d0e656 to your computer and use it in GitHub Desktop.
Save aobasar/7c74df8f40c813d0e656 to your computer and use it in GitHub Desktop.
Non www to www php redirection for IIS6
<?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