首页 文章

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

提问于
浏览
1

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

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

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

但我所有的旧网址都在谷歌索引,如果有任何人来到我的网站,它显示旧的URL和谷歌也索引新的URL . 它在网站问题上制作重复页面 .

让我知道解决方案

我的重写URL 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

    这是你的.htaccess文件:

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

    您需要通知Web爬虫有关重定向的信息,并使用301代码对其进行操作 .

  • 1

    出现规则是基于.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
    

    Note

    1)你的第二条规则似乎有一个拼写错误:sString = $ 6 NOT sString = $ 5

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

相关问题