使用rewrite重定向http到https

Apache httpd

RewriteEngine On
# RewriteCond %{SERVER_NAME} =www.example.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [L,R=301,QSA]

Nginx

rewrite ^ https://$server_name$uri permanent;