Think before you speak, read before you think.

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

by

in

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;
 }
}

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *