我想使用htaccess或php将旧网址重定向到新的重写网址

时间:2012-11-13 12:54:09

标签: php .htaccess url redirect rewrite

我有一个问题,因为我使用重写网址..

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

新重写网址 http://website.com/angry_birds_rio-appdetail-oWVi.html

但我所有的旧网址都在google中编入索引,如果有任何人访问我的网站,则会显示旧网址,Google也会显示新网址。它在网站问题上制作重复页面。

让我知道解决方案

我的重写网址htaccess

  

RewriteEngine On

     

RewriteRule ^([^ - ] ) - ([^ - ] ) - ([^ - ] ) - ([^ - ] ) - ([^ - ] *)。html $ index.php?appanme = $ 1& act = $ 2& appid = $ 3& page = $ 4& cat = $ 5 [L]

     

RewriteRule ^([^ - ] ) - ([^ - ] ) - ([^ - ] ) - ([^ - ] ) - ([^ - ] ) - ([^ - ] )。html $ index.php?appanme = $ 1& act = $ 2& appid = $ 3& page = $ 4& cat = $ 5& sString = $ 5 [L]

     

RewriteRule ^([^ - ] ) - ([^ - ] ) - ([^ - ] *)。html $ index.php?appanme = $ 1& act = $ 2& APPID = $ 3 L]

2 个答案:

答案 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代码对其进行操作。

答案 1 :(得分:0)

出现规则是基于.htaccess;如果存在一组CGI参数,则需要一组额外的规则来永久重定向(301)对index.php页面的BROWSER / CRAWLER请求到相应的别名,这将在几周内整理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 NOT sString = $ 5

2)如果您不清楚上述规则的作用,或者如果您想要更抽象的内容,请考虑以下mod_rewrite,那么Apache post文档值得一读。

相关问题