【问题标题】:I want to redirect old url to new rewrite url using htaccess or php我想使用 htaccess 或 php 将旧 url 重定向到新的重写 url
【发布时间】:2012-11-01 21:40:03
【问题描述】:

我有一个问题,因为我使用了重写 url..

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

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

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

告诉我解决办法

我的重写 URL htaccess

重写引擎开启

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

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

重写规则 ^([^-])-([^-])-([^-]*).html$ index.php?appanme=$1&act=$2&appid=$3[ L]

【问题讨论】:

标签: php .htaccess url redirect rewrite


【解决方案1】:

这是您的 .htaccess 文件:

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

您需要将重定向通知网络爬虫,您可以使用 301 代码进行。

【讨论】:

    【解决方案2】:

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

    【讨论】:

      猜你喜欢
      • 2016-01-24
      • 1970-01-01
      • 1970-01-01
      • 2015-09-14
      • 2022-06-11
      • 2017-09-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多