繁体   English   中英

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

[英]I want to redirect old url to new rewrite url using htaccess or php

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

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

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

但是我所有的旧网址都在google中建立了索引,如果有任何人进入我的网站,它会显示旧网址,而google也会显示新网址。 它使网站问题上的重复页面。

让我知道解决方法

我的重写URL htaccess

RewriteEngine开

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)BROWSER / CRAWLER对index.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文档。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM