使用nginx的301状态码:
server { listen 80; listen 443; server_name xxx.com; ssl on; ssl_certificate /data/www-key/xxx.pem; ssl_certificate_key /data/www-key/xxx.key; if ($scheme = http) { return 301 https://$server_name$request_uri; } }
Enjoy it !