wordpress域名跳转定向简单的方法

小站的地址改为www.77nn.net发现百度收录了很多以前的地址。修改了.htaccess发现只能首页跳转,文章页不能跳转。下面就来分享下内容页域名跳转重定向的简单代码吧

1.打开根目录下得wp-blog-header.php,在< ?php后面添加如下代码:

if (strtolower($_SERVER[‘SERVER_NAME’]) != ‘www.77nn.net)
{
$URIRedirect=$_SERVER[‘REQUEST_URI’];
if(strtolower($URIRedirect)==“/index.php)
{
$URIRedirect=“/”;
}
header(‘HTTP/1.1 301 Moved Permanently’);
header(‘Location:http://www.77nn.net’.$URIRedirect);
exit();
}
if (strtolower($_SERVER[‘SERVER_NAME’]) != ‘www.77nn.net’)
{
    $URIRedirect=$_SERVER[‘REQUEST_URI’];
    if(strtolower($URIRedirect)==“/index.php”)
    {
        $URIRedirect=“/”;
    }
    header(‘HTTP/1.1 301 Moved Permanently’);
    header(‘Location:http://www.77nn.net’.$URIRedirect);
    exit();
}
if (strtolower($_SERVER[‘SERVER_NAME’]) != ‘www.77nn.net’) { $URIRedirect=$_SERVER[‘REQUEST_URI’]; if(strtolower($URIRedirect)==“/index.php”) { $URIRedirect=“/”; } header(‘HTTP/1.1 301 Moved Permanently’); header(‘Location:http://www.77nn.net’.$URIRedirect); exit(); }
© 版权声明
THE END
喜欢就支持一下吧
点赞0赞赏 分享
Whatever I believed, I did; and whatever I did, I did with my whole heart and mind.
凡是我相信的,我都做了;凡是我做了的事,都是全身心地投入去做的
评论 共1条

请登录后发表评论

    暂无评论内容