php - nginx redirect http to https and let second-level domain name redirect to top-level domain name
習慣沉默
習慣沉默 2017-05-16 13:12:42
0
1
615

How can I redirect http to https and redirect second-level domain names to top-level domain names in the same nginx conf?

習慣沉默
習慣沉默

reply all(1)
phpcn_u1582

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;

}

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template