Apache .htaccess 功能汇总

HTTP 80 强制转 HTTPS

全站采用https协议访问,所以需要http重定向到https,只需要在.htaccess加入下面规则

在相应的网站根目录新建 .htaccess

语法一

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R,L]

语法二

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*) https://%{SERVER_NAME}/$1 [R,L]

强制301重定向 HTTPS

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


本站应网安备相关要求规定全站关闭留言板,如您需要留言欢迎到本站镜像站进行留言
点击前往vas.ink



Last modification:September 26th, 2019 at 02:54 am
If you think my article is useful to you, please feel free to appreciate

Leave a Comment