2013-01-12 40 views
0

在我的网站,我给了SEO purpose.My链接虚拟URL是像下面301重定向显示“该页没有正确重定向”错误

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

在这个URL女性上衣,长红班加罗尔这个字眼是虚拟的,基于物品id(491)页面正在加载。在491之后{{无论你会给它做什么都行}}。

为此,我要重定向page.If一些人给

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正在改变

+0

您的新网址也将属于'http://legacy.com/project/491/ {}任何',并会再次重定向不会它?你应该检查URL是否是这个,而不是再次重定向。 –

+0

没有它没有重定向,如果我给这样http://legacy.com/project/491/women url http://legacy.com/project/491/women-tops-long-red-bangalore但它显示错误 – Athi

+0

它不会去任何地方,因为你处于重定向循环。我想你正在尝试这在Firefox?在Chrome中打开相同的网址,错误消息将更明显 – Mathew

回答

3
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); 
} 
+0

我试过这个URL不会改变 – Athi

+0

< link rel =“canonical”href =“http://legacy.com/{$project_link}”> – Athi

+2

对不起,我不清楚。这个元素不会改变网址,但会通知搜索引擎,无论他们看到/ 491/{blah}有多少变化,它们都是真正的/ 491 /女性 - 顶级 - 红色 - 班加罗尔。这可以防止(可能)多个网址创建重复的内容问题,并且如果我在给页面加载时给这样的http://legacy.com/project/491/women搜索排名,就会丢失搜索排名 – Mathew