【发布时间】:2017-01-31 06:55:38
【问题描述】:
我有一个大约有 1000 个静态页面的网站,我想看看在我移动整个网站之前从 http 迁移到 https 将如何影响排名,例如 50 个页面。
我必须使用下面的第一个代码示例还是使用第二个就足够了?还是有更好的方法?
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} ^/page-1.htm/?.*$
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} ^/page-2.htm/?.*$
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} ^/page-3.htm/?.*$
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
# OR IS THIS ENOUGH:
Redirect 301 /page-1.htm https://www.example.com/page-1.htm
Redirect 301 /page-2.htm https://www.example.com/page-2.htm
Redirect 301 /page-3.htm https://www.example.com/page-3.htm
【问题讨论】:
-
第二个示例不起作用(除非您在单独的虚拟主机中拥有 HTTPS,并且您仅将其应用于非 HTTPS 主机)。第一个示例将不需要
RewriteEngine On的第二个或第三个实例。斯塔基恩的回应很棒
标签: .htaccess http redirect https