【发布时间】:2021-10-29 00:48:22
【问题描述】:
我用http协议很久了。多年后,我实施了域证书。现在我正在尝试使用 https:// 协议索引该网站,但 Google 仍然索引 http 协议。
我已经尝试了几件事。我在 DirectAdmin 中启用了“使用 https 重定向强制 SSL”选项。
我更改了我的 .htaccess,因此浏览器将每个选项重定向到 https 协议:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^[^.]+\.[^.]+$
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RedirectMatch permanent index.php/(.*) https://www.***.com/$1
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.(php|html) [NC]
RewriteRule ^index\.php$ https://www.***.com/ [R=301,L]
RewriteCond %{THE_REQUEST} ^GET\ /.*/index\.(php|html)\ HTTP
RewriteRule (.*)index\.(php|html)$ /$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^domain\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.domain\.com$
RewriteRule ^home\.html$ "https\:\/\/www\.domain\.com\/" [R=301,L]
RewriteCond %{HTTP_HOST} ^domain\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.domain\.com$
RewriteRule ^home$ "https\:\/\/www\.domain\.com\/" [R=301,L]
我创建了一个仅包含 https:// 协议的 sitemap.xml。
在 Google 搜索控制台中,我看到该网站今天已编入索引,并且“Google 选择的规范 URL”仍然是 http 协议。
有人知道我需要做什么来解决这个问题吗?
【问题讨论】:
-
你有一个
canonical链接元素,它被设置成什么? -
是的:
<link rel="canonical" href="https://www.example.com" /> -
我也尝试过删除规范链接元素,但结果是一样的。 https 协议未编入索引。 Google 仍然显示 http 结果
-
“我在 DirectAdmin 中启用了‘使用 https 重定向强制 SSL’选项。” - 这究竟是做什么的?您“切换到 HTTPS”有多久了?您是否在这个帐户上托管多个域?
标签: .htaccess http redirect mod-rewrite https