我有一个大约有 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
最佳答案
您可以使用单个规则重定向此格式的多个页面 page-n.htm
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule ^page-([0-9]+).htm$ https://%{HTTP_HOST}/page-$1.htm [NE,L,R=301]
关于.htaccess - 301 几个(但不是全部)http 到 https,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41951391/