2013-01-12 42 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