How can I redirect http to https and redirect second-level domain names to top-level domain names in the same nginx conf?
phpcn_u15822017-05-16 13:14:42
HTTP redirects to HTTPS (HTTPS listens to port 443. If you have multiple domain names on the same port, you need to set server_name)
server {
listen 80;
server_name domain.com;
rewrite ^(.*)$ https://$host permanent;
}
Second-level domain name redirects to top-level domain name:
server {
listen 80;
server_name *.domain.com;
rewrite ^/(.*) http://domain.com/ permanent;
}