Revision: 32516
Updated Code
at September 27, 2010 19:00 by r4b87
Updated Code
$domain=$_SERVER['HTTP_HOST'];
if(substr($domain, 0, 3)!='www'){
$redirect_url="http://www.{$domain}{$_SERVER['REQUEST_URI']}";
if($_SERVER['QUERY_STRING']!=''){
$redirect_url.="?{$_SERVER['QUERY_STRING']}";
}
header('HTTP/1.1 301 Moved Permanently');
header("Location: {$redirect_url}");
exit();
}
Revision: 32515
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at September 27, 2010 18:58 by r4b87
Initial Code
$domain=$_SERVER['HTTP_HOST'];
if(substr($domain, 0, 3)!='www'){
$redirect_url="http://www.{$domain}{$_SERVER['REQUEST_URI']}";
if($_SERVER['QUERY_STRING']!=''){
$redirect_url.="?{$_SERVER['QUERY_STRING']}";
}
header('HTTP/1.1 301 Moved Permanently');
header("Location: {$redirect_url}");
exit();
}
Initial URL
Initial Description
This code wil 301 redirect non-www URLs to the www URL
Initial Title
Redirect non-www URLs
Initial Tags
php, redirect
Initial Language
PHP