Nginx如何配置http强制转为https?

已邀请:

zkbhj - 凯冰科技站长

赞同来自:

#先监听80端口,为http请求,然后强制转发到https监听的443端口上面
server {
listen 80;
root path;
server_name www.exp.com;
rewrite ^(.*) https://$server_name$1 permanent;
}

#监听443端口,https请求
server {
listen 443 ssl;
root path;
server_name www.exp.com;
ssl_certificate 证书文件.crt;
ssl_certificate_key 证书文件.key;

#此段代码为rapidPHP单一入库配置,不是rapidPHP框架请忽略
#location / {
# if (!-e $request_filename){
# rewrite ^(.*)$ /index.php?__ROUTE__=$1 last;
# }
#}

location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}

要回复问题请先登录注册