繁体   English   中英

301重定向显示“页面未正确重定向”错误

[英]301 redirection showing “The page isn't redirecting properly” error

在我的网站上,我提供了一个用于SEO的伪URL。我的链接如下

http://legacy.com/project/491/women-tops-long-red-bangalore

在此网址中,该文字是假的,基于页面正在加载的id(491)项目。在491 / {之后,您将提供的任何信息都可以使用}。

为此,我想重定向页面。如果有人给

 http://legacy.com/project/491/{any}

想要重定向到

 http://legacy.com/project/491/women-tops-long-red-bangalore

我给出了以下代码

  if(isset($_GET['item_id']))
         {
           Header("HTTP/1.1 301 Moved Permanently" );
           Header("Location: http://".$_SERVER['HTTP_HOST'].$project_link);   
        }

在$ project_link中,我正在调用一个函数,它将根据项目ID返回一个字符串,如下所示

 "/project/491/women-tops-long-red-bangalore" 

但显示错误“页面无法正确重定向”,但网址正在更改

http://legacy.com/project/491/women-tops-long-red-bangalore

匹配模式

http://legacy.com/project/491/{any}

重定向到:

http://legacy.com/project/491/women-tops-long-red-bangalore

匹配模式:

http://legacy.com/project/491/{any}

重定向到:

http://legacy.com/project/491/women-tops-long-red-bangalore

匹配模式:

http://legacy.com/project/491/{any}

...

我不是强制执行该URL,而是通过在页面顶部添加规范标签来消除重复的内容问题:

<link rel="canonical" href="http://legacy.com/project/491/women-tops-long-red-bangalore">

或者您可以打破PHP中的循环

if(isset($_GET['item_id']) && $_SERVER['REQUEST_URI'] != $project_link)
{
    Header("HTTP/1.1 301 Moved Permanently" );
    Header("Location: http://".$_SERVER['HTTP_HOST'].$project_link);   
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM