nginx http访问自动跳转https

2020-05-20 325

http请求通过rewrite重写到https上,前提已经安装SSL证书

修改nginx的nginx.conf配置文件,添加如下代码
#http跳转https server{ listen 80; server_name www.itwps.com; #要访问的域名,这里是http rewrite ^(.*)$ https://www.itwps.com; #自动跳转到https协议 location ~ / { index index.html index.php index.htm; } }
1 0