apache 环境配置https后,网站http跳转至https

入口文件.htaccess如下


<IfModule mod_rewrite.c>
Options +FollowSymlinks -Multiviews
RewriteEngine On

RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://%{SERVER_NAME}/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [L,E=PATH_INFO:$1]

</IfModule>

注意上面的 R=301,这里不指定的话会默认是302(临时跳转),对SEO的优化不友好

猜你喜欢

转载自www.cnblogs.com/yangfei123/p/11806248.html