Suppose that you're the maintainer of www.example.com and the site is served by Nginx, you may redirect the followig sites to https://www.example.com
(url with www subdomain and https schema):
server {
listen 80;
server_name _;
return 301 https://www.example.com$request_uri;
}
server {
listen 443 ssl;
server_name example.com;
ssl_certificate /path/to/crt;
ssl_certificate_key /path/to/key;
return 301 https://www.example.com$request_uri;
}
server {
listen 443 ssl;
server_name www.example.com;
ssl_certificate /path/to/crt;
ssl_certificate_key /path/to/key;
location / {
proxy_pass http://127.0.0.1:8080;
}
}
Notice:
server
directive redirect all http request.server
directive redirect non-www request.server
directive gives the detailed configuration of this site like location
directives.