.htaccess - SSL 证书 & Htaccess & SEO

标签 .htaccess http ssl https seo

我想将 ssl 证书添加到我的新闻站点。但是不想通过将 http url 更改为 https 来获得 SEO 惩罚或 seo 排名降低..

我的 htaccess 文件现在是这样的:

RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

我打算像这样改变它:

RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http**s**://www.%{HTTP_HOST}/$1 [R=301,L]

此外,我会将所有 http url 转换为 html 源中的 https...

是否足以不被 Google 惩罚?

最佳答案

您将 http url 更改为 https,但前提是该 url 没有 www

改用:

# Without IP
RewriteCond %{HTTP_HOST} ^[0-9.]+$
RewriteRule ^ - [L]

RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [NE,L,R=301]
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [NE,L,R=301]

或者如果您将它与其他规则一起使用:

RewriteCond %{HTTP_HOST} !^(?:www\.|[0-9.]+$) [NC]
RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [NE,L,R=301]
RewriteCond %{HTTP_HOST} !^[0-9.]+$
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [NE,L,R=301]

关于.htaccess - SSL 证书 & Htaccess & SEO,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33698737/

相关文章:

Wordpress https ssl 内容被阻止的错误

javascript - 如何在源代码中使用 JavaScript 将每个 http 更改为 https?

http - YouTube 如何防止视频内容被保存/重新分发?

node.js - req.setTimeout 和 socket.setTimeout 有什么区别?

ssl - OpenLDAP - TDS - 无法联系 LDAP 服务器 (-1)

node.js - 如何查看 NodeJS SSL 协商结果

php - 如何保护用户注册?

php - 如何使用 errordocument 重定向到同一文件夹中的 php 文件?

php - 如何从 URL 中删除这种类型的字符串 #VTkfzCGqqkow

php - 如何在.htaccess 中设置upload_max_filesize?