【问题标题】:301 redirection showing "The page isn't redirecting properly" error301 重定向显示“页面未正确重定向”错误
【发布时间】:2013-01-12 04:40:18
【问题描述】:

在我的网站中,我为 SEO 提供了一个虚拟 URL。我的链接如下所示

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

在这个 URL women-tops-long-red-bangalore 中,这个措辞是虚拟的,基于页面正在加载的项目 id(491)。在 491/{whatever you will give it will work}之后。

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

 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" 

但它显示错误“页面未正确重定向”但网址正在更改

【问题讨论】:

  • 您的新 URL 也会在 http://legacy.com/project/491/{any} 下,并且会再次重定向,不是吗?您应该检查 URL 是否是那个,而不是再次重定向。
  • 不,如果我给legacy.com/project/491/women url 更改legacy.com/project/491/women-tops-long-red-bangalore 这样但它显示错误,它不会重定向
  • 它不会去任何地方,因为您处于重定向循环中。我猜你正在Firefox中尝试这个?在Chrome中打开相同的url,错误信息会更明显
  • 在 chrome 中出现错误“此网页有重定向循环”
  • 是的,那个重定向循环是什么意思,我该如何解决它

标签: php seo smarty http-redirect


【解决方案1】:
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}

...

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

<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);   
}

【讨论】:

  • 对不起,我不清楚。此元素不会更改 url,但会通知搜索引擎无论他们看到多少 /491/{blah} 的变体,它们都是真正的 /491/women-tops-long-red-bangalore。这将防止(可能)多个网址创建重复的内容问题和搜索排名的损失
  • 如果我在页面加载时给出这样的legacy.com/project/491/women。但是 url 没有变成这个legacy.com/project/491/women-tops-long-red-bangalore
  • 好的,但我们的 seo 团队希望重定向到原始 URL legacy.com/project/491/women-tops-long-red-bangalore
  • 好的,如果你必须在浏览器栏中有那个 url,那么你可以使用 PHP 来防止循环。查看编辑。
  • 还有一个疑问,如果条件我没有添加这个 && $_SERVER['REQUEST_URI'] != $project_link 但对我来说它不起作用告诉我原因,我也尝试过这个
猜你喜欢
  • 1970-01-01
  • 2019-07-05
  • 2014-09-29
  • 2014-03-12
  • 2016-03-25
  • 2017-09-07
  • 1970-01-01
  • 1970-01-01
  • 2017-01-18
相关资源
最近更新 更多