2012-11-13 28 views
0

我,因爲我使用重寫URL有問題重定向舊網址到新的URL重寫..我想用的htaccess或PHP

我的舊網址: Website.com/index.php?act=appdetail&appid=oWV

新的重寫URL http://website.com/angry_birds_rio-appdetail-oWVi.html

但我所有的舊網址在谷歌索引,如果有人來我的網站顯示舊網址和谷歌還INDEXED新網址。其在網站上製作複製頁面的問題。

讓我知道解決的辦法

我重寫URL的htaccess

RewriteEngine敘述在

重寫規則^([^ - ] ) - ([^ - ]) - ([^ - ] ) - ([^ - ]) - ([^ - ?] *)HTML $的index.php appanme = $ 1 &行爲= $ 16 &的appid = $ 3 &頁= $ 4 &貓= $ 5 L]

重寫規則^([^ - ] ) - ([^ - ]) - ([^ - ] ) - ([^ - ]) - ([^ - ] ) - ([^ - ])的.html $的index.php appanme = $ 1 &行爲= $ 16 &的appid = $ 3 &頁= $ 4 &貓= $ 5 & sString = $ 5 L]

重寫規則^([^ - ?] ) - ([^ - ]) - ([^ - ] *)。html $ index.php?appanme = $ 1 & act = $ 2 & appid = $ 3 [L]

+2

http://stackoverflow.com/questions/12460515/redirect-php-page-to-another-php-page-using-301-htaccess –

+0

它沒有幫助我..我需要一個解決方案..我不是好的htaccess –

+0

謝謝大家,我只是找到一種方式.. –

回答

1

這裏是你的.htaccess文件:

RewriteEngine on 
RewriteRule ^/index.php?act=appdetail&appid=oWV$ http://website.com/angry_birds_rio-appdetail-oWVi.html [R=301,L] 

你需要告知網絡抓取工具對重定向,你有一個301碼CANDO它。

0

出現規則是基於.htaccess的;您需要一套額外的規則來將index.php頁面的BROWSER/CRAWLER請求(如果存在一組CGI參數)永久重定向(301)到適當的別名,這將在幾周內整理Google。然後你的規則在上面

RewriteEngine On 
RewriteBase/

#Permanently redirect BROWSER requests for the index.php?xxx to the appropriate page alias: 
RewriteCond %{THE_REQUEST}  /index.php  [NC] 
RewriteCond %{QUERY_STRING}  ^appanme=([^&]+)&act=([^&]+)&appid=([^&]+)&page=([^&]+)&cat=([^&]+)&sString=([^&]+) [NC] 
RewriteRule ^.*     http://%{HTTP_HOST}/%1-%2-%3-%4-%5-%6.html [R=301,L] 

RewriteCond %{THE_REQUEST}  /index.php  [NC] 
RewriteCond %{QUERY_STRING}  ^appanme=([^&]+)&act=([^&]+)&appid=([^&]+)&page=([^&]+)&cat=([^&]+) [NC] 
RewriteRule ^.*     http://%{HTTP_HOST}/%1-%2-%3-%4-%5.html [R=301,L] 

RewriteCond %{THE_REQUEST}  /index.php  [NC] 
RewriteCond %{QUERY_STRING}  ^appanme=([^&]+)&act=([^&]+)&appid=([^&]+) [NC] 
RewriteRule ^.*     http://%{HTTP_HOST}/%1-%2-%3.html [R=301,L] 

# Followed by: YOUR RULES FROM ABOVE 

1)似乎有一個錯字在你的第二規則:sString = $ 6中未sString = $ 5

2)的Apache mod_rewrite文檔值得一讀如果你不清楚上述規則是做什麼的,或者如果你想要一些更抽象的東西,請考慮以下內容post