【问题标题】:How to solve url canonicalization?如何解决 url 规范化?
【发布时间】:2012-05-29 13:09:29
【问题描述】:

网址http://www.example.com/http://www.example.com/index.html 都显示相同的网页。但搜索引擎将它们视为 2 个不同的网址。因此,页面排名存在分裂并影响 SEO。

我在网络搜索后得到的可能解决方案:

1.Use DirectoryIndex index.html in the .htaccess file.

这告诉搜索引擎http://www.example.com/http://www.example.com/index.html 是相同的。

我面临的问题:.htaccess 文件中的 DirectoryIndex index.html 要求所有子文件夹也有 index.html 文件。前任。如果根目录中有一个文件夹“blog”,其中没有 index.html 文件,则 url "http://www.example.com/blog/" 抛出 index not found 错误。

2.using 301 redirect. Redirect http://www.example.com/index.html to http://www.example.com/

问题:重定向会增加加载时间。这不是一个好习惯。

请建议哪种解决方案更好?我怀疑第一个是否是解决方案。 另外,如果我必须重定向,将http://www.example.com/index.html 重定向到http://www.example.com/ 更好,反之亦然?

【问题讨论】:

    标签: seo canonical-link


    【解决方案1】:

    只需使用canonical URLs。这将很容易解决问题。如有必要,您还可以从 index.html 到 / 进行 301 重定向,因为这也可以完成同样的事情。

    【讨论】:

    • 示例站点是“example.com/product.php?item=swedish-fish”,但我有 root(example.com) 和 index.html。如果我只是在 index.html 文件中添加 example.com"> ,这个解决方案会起作用吗?
    • @Sangam254 - 是的。你想要<link rel="canonical" href="http://www.example.com/" />
    猜你喜欢
    • 2012-05-22
    • 1970-01-01
    • 1970-01-01
    • 2023-02-09
    • 2011-02-28
    • 2010-09-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多