Https force redirect without www 301
Many browsers are gradually updated to websites that only support https. Therefore, many http websites need to add https support. In this case, the jump between www and without www is required, because www and without www use different certificates, 301 redirection is required. The solution is as follows:
Here, we use www.bkjia.com and testhttps.com as examples to modify the configuration file corresponding to www.bkjia.com in the Nginx configuration file:
Server {
Listen 80;
Server_name bkjia.com www.bkjia.com;
Return 301 https://www.bkjia.com $ request_uri;
}
Server {
Listen 443 ssl;
Ssl_certificate/bkjia.com/cert.pem;
Ssl_certificate_key/bkjia.com/privkey.pem;
Server_name bkjia.com;
Return 301 https://www.bkjia.com $ request_uri;
}
Server {
Listen 443 ssl;
Ssl_certificate/www.bkjia.com/cert.pem;
Ssl_certificate_key/www.bkjia.com/privkey.pem;
Server_name www.bkjia.com;
}
Description:
The first code is