例如将所有的www.nihao.com域名的http访问逼迫跳转到https。下面配置均可以实现:server { listen 80; server_name www.nihao.com; index index.html index.php index.htm; access_log /usr/local/nginx/logs/8080-access.log main; error_log /usr/local/nginx/logs/8080-error.log; #重点在此 if ($host ~ "^nihao.com$") { rewrite ^/(.)$ https://www.nihao.com/ permanent; } location ~ / { root html; index index.html index.php index.htm; }}网站添加了https证书后,当http办法访问网站时就会报404缺点,以是须要做http到https的逼迫跳转设置.---------------一、采取nginx的rewrite方法---------------------下面是将所有的http要求通过rewrite重写到https上。
html域名识别跳转http要求域名强迫跳转https
小编