【问题标题】:Duplicated search results because of mod_rewrite由于 mod_rewrite 导致重复的搜索结果
【发布时间】:2012-06-11 03:13:27
【问题描述】:

我有典型的 mod_rewrite 规则来使 url 更漂亮

RewriteRule ^most-viewed$ index.php?time=1
RewriteRule ^most-viewed-week$ index.php?time=2

但不知何故,Google 也设法获得了 index.php?time= 版本,所以现在,在 google 搜索结果中,两个结果都显示,一个带有 mod_rewrite url,一个是“常规”。

恐怕这对 seo 不利,因为这可能被视为“重复内容”。

我怎样才能避免“常规”索引被索引,甚至更好,使其对所有人都无法访问。

如果有帮助,我会使用 PHP。

【问题讨论】:

标签: php .htaccess mod-rewrite seo


【解决方案1】:

尝试使用 Google 网站管理员工具绕过 URL 重写问题,并使用“URL 参数”忽略它。 您可以在 Dashboard> 配置下找到它

【讨论】:

    【解决方案2】:

    您可以为任何直接访问它的人返回 Forbidden 或 Gone 响应。

    RewriteRule ^index.php\?time=(1|2)$ [F,L]
    

    .. 告诉它返回 '403 Forbidden' 并结束。

    您还应该作为标准包含一个规范的元标记:

    <link rel="canonical" href="http://yourdomain.com/most-viewed" />
    

    也可以看看:

    http://googlewebmastercentral.blogspot.com.au/2009/02/specify-your-canonical.html

    已编辑 逃脱了 ?time= 部分..

    【讨论】:

    • 这似乎没有任何作用,如果我取出 ?time=(1|2) 则它可以工作,但如果变量存在,它似乎没有任何作用。
    • 抱歉,Tebb, ?time= 应该像 \?time= 一样转义,我已经修改了我的回复
    猜你喜欢
    • 1970-01-01
    • 2011-08-18
    • 2023-03-22
    • 1970-01-01
    • 1970-01-01
    • 2020-03-19
    • 1970-01-01
    • 2013-02-25
    • 1970-01-01
    相关资源
    最近更新 更多