Slogan
Home > Linux

.htaccess http访问跳转至https

RewriteEngine on
RewriteBase /
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]

或者

RewriteEngine on
RewriteBase /
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R=301]
RewriteRule ^(.*)?$ https://%{SERVER_NAME}/$1 [L,R]

上一篇:.htaccess解决跨域访问资源问题
下一篇:Centos7 修改SSH 端口
Apache,htaccess