I have SSL issued for domain.com. Now these url works fine:
http://www.example.com -> https://example.com
http://example.com -> https://example.com
https://example.com
But when accessed with https://www.example.com it shows the Security Certificate error as:
There is a problem with this website’s security certificate.
My nginx config (site-available/example.com) is as follows:
server {
server_name www.example.com;
return 301 https://example.com$request_uri;
}
server {
listen 80;
server_name example.com;
return 301 https://example.com$request_uri;
}
server {
listen 443;
server_name example.com;
ssl on;
ssl_certificate /etc/ssl/certs/example_com.crt;
ssl_certificate_key /etc/ssl/private/example.key;
...
...
...
How can I redirect the url https://www.example.com to https://example.com in this config file