Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 将我的站点迁移到HTTPS_Php_.htaccess_Seo - Fatal编程技术网

Php 将我的站点迁移到HTTPS

Php 将我的站点迁移到HTTPS,php,.htaccess,seo,Php,.htaccess,Seo,我在服务器上安装了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] 或者我

我在服务器上安装了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页中的每一页:

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

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

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

这是我多年来一直使用的,效果很好

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

不需要设置301状态,Apache将自动设置
302 Found
状态,这对谷歌来说很好,因为这样做后我的网站排名提高了。

SEO相关问题可能更适合澄清一下,可以对所有页面进行站点范围的重定向吗?是的,完全可以。它适用于所有请求,包括图像、带有GET参数的请求等。