【问题标题】:.htaccess redirects - updated site (301 appropriate?).htaccess 重定向 - 更新的站点(301 合适?)
【发布时间】:2012-10-12 08:47:14
【问题描述】:

我在更新我的网站时遇到了问题,谷歌搜索结果显示了指向旧页面的链接,这些链接现在是 404,其中一些甚至包含已弃用的内容。

我的问题是关于 301 的使用。旧页面具有深度嵌套的页面,如下例所示:

    www.site.com/category/subjects/subject_b.html

它显示在 google 中,带有非常具体的“subject_b”描述,这对我的目的来说不是最佳的。

我一直在处理的新布局意味着曾经位于“/category/subjects/subject_b”下的内容现在可以在单个页面 (www.site.com/subjects.html) 中找到,以及假设的主题_a & 主题_c。

这样重定向旧页面会不会出错?

    redirect http://www.site.com/category/subjects/subject_a.html http://www.site.com/subjects.html
    redirect http://www.site.com/category/subjects/subject_b.html http://www.site.com/subjects.html
    redirect http://www.site.com/category/subjects/subject_c.html http://www.site.com/subjects.html

另外,我将如何处理包含谷歌描述且内容不在新的等效页面上的页面?

如果有人能为我阐明这一点,或者指出我可以在哪里阅读更多相关信息的正确方向,我会很高兴!

【问题讨论】:

    标签: .htaccess redirect seo


    【解决方案1】:

    这样重定向旧页面会不会出错?

    您将删除 http://www.site.com 部分。这应该足够了:

    Redirect 301 /category/subjects/subject_a.html /subjects.html
    Redirect 301 /category/subjects/subject_b.html /subjects.html
    Redirect 301 /category/subjects/subject_c.html /subjects.html
    

    甚至:

    RedirectMatch 301 ^/category/subjects/subject(.*) /subjects.html
    

    涵盖所有 3 个。

    如果您有多个域都指向同一个文档根目录,并且您实际上需要匹配特定域的路径,则可以使用 mod_rewrite:

    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^(www\.)?site.com$ [NC]
    RewriteRule ^/?category/subjects/subject(.*) /subjects.html [L,R=301]
    

    【讨论】:

    • 您好,感谢您的快速回复!另外:您对搜索结果描述有什么看法(谷歌机器人会在 301 后更改这些描述并且我通过网站管理员工具重新索引)?
    猜你喜欢
    • 2015-08-22
    • 1970-01-01
    • 1970-01-01
    • 2015-05-06
    • 2018-05-01
    • 2017-02-06
    • 2019-07-03
    • 2012-12-17
    • 2017-09-21
    相关资源
    最近更新 更多