将我的站点迁移到 HTTPS

Migrating my site to HTTPS

我在服务器上安装了 SSL,效果很好。假设我有 10 html/php 页。

这里是我对什么最适合 SEO 感到困惑的地方:

在我的 .htaccess 文件中,我是否在全站范围内(所有 10 个页面)301 重定向:

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

或者我应该重定向 10 个页面中的每一个:

第 1 页:

RewriteCond %{SERVER_PORT} !^443$
RewriteCond %{HTTPS} !on
RewriteCond %{REQUEST_URI} ^/page1.php$ [NC]
RewriteRule ^(.*)$ https://www.example.com/page1.php/ [L,R=301]

第 2 页:

RewriteCond %{SERVER_PORT} !^443$
RewriteCond %{HTTPS} !on
RewriteCond %{REQUEST_URI} ^/page2.php$ [NC]
RewriteRule ^(.*)$ https://www.example.com/page2.php/ [L,R=301]

这是我用了很多年的,效果很好

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

无需设置 301 状态,Apache 会自动设置 302 Found 状态并且 Google 没问题,因为这样做后我的网站排名提高了。