1.rewrite
server { listen 80; server_name test.com; rewrite ^(.*)$ https://$host$1 permanent; }
2. nginx状态码 497重定向
server { listen 443; listen 80; server_name a.com; ssl on; ssl_certificate /etc/nginx/test.pem; ssl_certificate_key /etc/nginx/test.key; error_page 497 https://$host$uri?$args; }
3.页面刷新
<html> <meta http-equiv="refresh" content="0;url=https://a.com/"> </html>
server { listen 80; server_name a.com; location / { root /www/; } error_page 404 https://a.com/; }