windows server 2003 服务器 Wordpress 设置301的方法。
修改wordpress 根目录下的wp-blog-header.php ,并在文件开头 <?php 之后加入以下代码:
if (strtolower($_SERVER['SERVER_NAME'])!='你的主域名')
{
$URIRedirect=$_SERVER['REQUEST_URI'];
if(strtolower($URIRedirect)=="/index.php")
{
$URIRedirect="/";
}
header('HTTP/1.1 301 Moved Permanently');
header('Location: http://你的主域名' .$URIRedirect);
exit();
}
注意:把上面程序里面的两个“你的主域名”修改成你自己的的主域名即可。
文章评论