apache/nginx某目录abc强制https访问

apache

把如下代码写一个.htaccess,丢到/abc/里面

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

nginx

配置文件里写

location /abc/ {
 if ( $scheme = 'http' ) {
 rewrite ^(.*)$ https://$host$1 permanent;
 }
}

发表评论

电子邮件地址不会被公开。 必填项已用*标注

This site uses Akismet to reduce spam. Learn how your comment data is processed.