【问题标题】:Redirect a test link to an old one if coming from Google如果来自 Google,将测试链接重定向到旧链接
【发布时间】:2013-10-31 04:23:42
【问题描述】:

因此,在为客户做项目时,.htaccess 的一些问题导致 Google 引用了一个测试 URL。哪个不是超级...

所以,我想知道是否可以在某些情况下重定向到实时 URL

【问题讨论】:

    标签: .htaccess seo


    【解决方案1】:

    将此添加到您的网络根/ 目录中的.htaccess

    RewriteEngine on
    RewriteBase /
    
    RewriteCond %{HTTP_USER_AGENT} googlebot [NC,OR]
    RewriteCond %{HTTP_REFERER} ://[^.]+\.google\. [NC]
    RewriteRule ^test/page\.php$ http://domain.com/live/page.php [R=301,NC,L]
    

    【讨论】:

    • 问题是,我们仍然可以访问测试,嗯,测试 :) 它只需要来自 Google 时:/
    • 您在生产环境中进行测试? :)
    • 我们有两台不同的服务器,但我们在某个时候意外删除了 .htpasswd,并且一页有时间被编入索引......无论如何,看起来它有效,谢谢 :)
    【解决方案2】:

    你可以有这个规则:

    ##  check if it is coming from google
    RewriteCond %{HTTP_REFERER} ^https?://(www\.)?google\. [NC] 
    RewriteRule ^test/?$ /live/ [NC,L,R=301]
    

    【讨论】:

      猜你喜欢
      • 2013-01-10
      • 2019-11-06
      • 2016-02-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-05-25
      • 1970-01-01
      相关资源
      最近更新 更多