Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/227.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 301重定向显示“;页面不是';t正确重定向“;错误_Php_Seo_Smarty_Http Redirect - Fatal编程技术网

Php 301重定向显示“;页面不是';t正确重定向“;错误

Php 301重定向显示“;页面不是';t正确重定向“;错误,php,seo,smarty,http-redirect,Php,Seo,Smarty,Http Redirect,在我的网站上,我提供了一个虚拟的网址用于搜索引擎优化。我的链接如下 http://legacy.com/project/491/women-tops-long-red-bangalore 在这个URL长的红色班加罗尔,基于页面正在加载的项目id(491),这个单词是虚拟的。在491之后/{不管你给它什么都可以} 为此,我想重定向页面。如果有人给出 http://legacy.com/project/491/{any} 要重定向到 http://legacy.com/project/491

在我的网站上,我提供了一个虚拟的网址用于搜索引擎优化。我的链接如下

http://legacy.com/project/491/women-tops-long-red-bangalore
在这个URL长的红色班加罗尔,基于页面正在加载的项目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" 
但它显示错误“页面没有正确重定向”,但url正在更改

http://legacy.com/project/491/women-tops-long-red-bangalore
符合模式

http://legacy.com/project/491/{any}
http://legacy.com/project/491/{any}
它重定向到:

http://legacy.com/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/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">
符合模式

http://legacy.com/project/491/{any}
http://legacy.com/project/491/{any}
它重定向到:

http://legacy.com/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/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">

您的新URL也将位于
http://legacy.com/project/491/{any}
并且会再次重定向,不是吗?你应该检查URL是否是那样,不要再重定向。不,如果我给URL这样的更改,它不会重定向,但它显示错误它不会去任何地方,因为你在重定向循环中。我猜你是在Firefox上尝试这个?在Chrome中打开相同的url,错误消息将更加明显在Chrome中错误“此网页有重定向循环”是的,redierct循环意味着我如何解决它您的新url也将位于
http://legacy.com/project/491/{any}
并且会再次重定向,不是吗?你应该检查URL是否是那样,不要再重定向。不,如果我给URL这样的更改,它不会重定向,但它显示错误它不会去任何地方,因为你在重定向循环中。我猜你是在Firefox上尝试这个?在Chrome中打开相同的url,错误消息将更加明显在Chrome中错误“此网页有重定向循环”是的,redierct循环意味着什么?对不起,我不清楚。这个元素不会改变url,但会通知搜索引擎,无论他们看到多少个/491/{blah}的变体,它们都是真正的/491/women-tops-long-red-bangalore。这将防止(可能的)多个URL创建重复的内容问题,并防止在加载页面时丢失搜索权限。但是url并没有变为这个ok,但是我们的seo团队希望重定向到原始url ok,如果你必须在浏览器栏中有那个url,那么你可以使用PHP来防止循环。查看编辑。1更多疑问,如果我没有添加此服务器,我也尝试了此操作&&$\u服务器['REQUEST\u URI']!=$project_link但对我来说它不起作用告诉我答案,我不清楚。这个元素不会改变url,但会通知搜索引擎,无论他们看到多少个/491/{blah}的变体,它们都是真正的/491/women-tops-long-red-bangalore。这将防止(可能的)多个URL创建重复的内容问题,并防止在加载页面时丢失搜索权限。但是url并没有变为这个ok,但是我们的seo团队希望重定向到原始url ok,如果你必须在浏览器栏中有那个url,那么你可以使用PHP来防止循环。查看编辑。1更多疑问,如果我没有添加此服务器,我也尝试了此操作&&$\u服务器['REQUEST\u URI']!=$项目链接但对我来说不起作用告诉我原因