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



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

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

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

但是我所有的旧网址都在谷歌中被索引,如果有人来到我的网站,它会显示旧网址,谷歌也索引了新网址。 它在网站上制作重复页面的问题。

让我知道解决方案

我的重写网址访问

重写引擎打开

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]

这是你的 .htaccess 文件:

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

您需要通知网络爬虫有关重定向的信息,您可以使用 301 代码来完成。

看起来规则是基于 .htaccess 的;您需要一组额外的规则来永久重定向 (301) 浏览器/爬虫对索引.php页面的请求,如果存在一组 CGI 参数,到适当的别名,这将在几周内整理 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)Apache mod_rewrite文档值得一读,如果你不清楚上述规则的作用,或者如果你想要一些更抽象的东西,请考虑以下帖子。

最新更新