【问题标题】:I'm having a problem with seo and htaccess, crawlers check twice my site我在使用 seo 和 htaccess 时遇到问题,爬虫检查了我的网站两次
【发布时间】:2020-11-28 12:00:34
【问题描述】:

我正在尝试优化我的 SEO,我正在尝试一些网站,例如 sitechecker dot pro

我仍然不知道为什么它将我的网站读取为两个网站,即域和index.html

这是我的.htaccess 文件:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} !^www.example.com$
RewriteRule (.*) https://www.example.com/$1 [L,R=301]

<ifModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file .(html?|txt|css|js|php|pl)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</ifModule>

我也有 SSL,但我仍然不知道是什么问题。

顺便说一下,我的规范网址是:

 <!-- Canonical URL -->
 <link rel="canonical" href="/index.html" />

希望我能得到一些帮助,在此先感谢。

【问题讨论】:

  • 为您的网站添加 robots.txt

标签: html .htaccess seo


【解决方案1】:
<!-- Canonical URL -->
<link rel="canonical" href="/index.html" />

也许你刚刚更新了这个,但这不是你的页面状态:

<!-- Canonical URL -->
<link rel="canonical" href="https://www.example.com/" />

...这确实是首选 URL(即没有index.html)。它也是您在页面上大部分链接到的 URL。

但是,您仍然从您的徽标链接到 index.html。这需要更正为简单的href="/"

您需要确保您在整个网站中仅链接到这些 URL 之一。

一旦您更正了所有内部链接,您就可以在.htaccess 中实施重定向,以便为搜索引擎和任何可能关注书签或第 3 方链接的用户更正此问题。

例如,要从 URL 中删除 index.html,您可以在 .htaccess 文件的顶部添加以下内容(紧跟在 RewriteEngine On 指令之后):

RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^index\.html$ / [R=301,L]

但这必须在所有内部链接都已更正后才能实施。

首先使用 302(临时)重定向进行测试以避免缓存问题。

前面的 RewriteCond 指令是为了确保我们不会出现重定向循环(因为 mod_dir 为 index.html 发出内部子请求)。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-07-05
    • 1970-01-01
    • 2018-06-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多