【问题标题】:Redirect bots to static version of site将机器人重定向到站点的静态版本
【发布时间】:2015-07-30 11:00:19
【问题描述】:

基本上,我想使用 .htaccess 文件将机器人从常规站点重定向到静态版本。

情况如下: 我网站中的 URL 采用以下格式:

http://example.com/?p=something
http://example.com/index.html?p=something
http://example.com/basic.php?p=something

我想使用 .htaccess 文件将爬取前 2 个 URL 之一的机器人重定向到第三个,方法是用 basic.php 替换 index.html 或添加它(如果它不存在)。根也应该变成 basic.php 而不是 index.html。

这是我当前的 .htaccess 文件,这是错误的,因为它仅在 URL 包含 index.html 时才有效

RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} (googlebot|InfoSeek|msnbot|bingbot|Slurp|DuckDuckBot) [NC]
RewriteRule ^index\.html$ /basic.php [L,R]

如果有好心人能帮我解决这个问题,将不胜感激。谢谢

【问题讨论】:

    标签: .htaccess mod-rewrite redirect seo


    【解决方案1】:
    http://example.com/?p=something
    http://example.com/index.html?p=something
    

    要匹配这两者中的任何一个,您只需将模式(即 URL 路径)设为可选:

    RewriteRule ^(index\.html)?$ /basic.php [L,R]
    

    除此之外:从 SEO 的角度来看,这有点可疑。它可能被视为“伪装”——向搜索引擎提供与用户不同的内容,这可能会产生负面影响。并且搜索引擎显然希望索引您的静态站点(被重定向到的页面),而不是“用户”看到的站点。

    【讨论】:

      猜你喜欢
      • 2015-04-01
      • 2022-01-18
      • 1970-01-01
      • 2017-09-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-02-17
      相关资源
      最近更新 更多