windows主机安装wordpress利用php实现301重定向

11-15 | 夜光 | IT记录

在网站根目录index.php文件中,其它语句前面加入以下代码:

//301_Redirect
$the_host = $_SERVER['HTTP_HOST'];//取得当前域名
if(strtolower($the_host) != 'boliquan')//把这里的域名换上你想要的
{
	$URIRedirect=$_SERVER['REQUEST_URI']; //获取域名后的参数
	if(strtolower($URIRedirect)=="/index.php")//判断是参数为/index.php就显示为/
	{
	$URIRedirect="/";
	}
	header("HTTP/1.1 301 Moved Permanently");//发出301头部
	header("Location: /".$URIRedirect);//跳转到你希望的地址格式
	exit();
}
本文标签: ,
本文链接: windows-wordpress-php-301-redirect/
版权所有: 玻璃泉, 转载请注明本文出处。