I'm confused, does this additional server block will redirect ANY subdomain to https://example.com
?
server {
server_name www.example.com
return 301 https://example.com$request_uri;
}
As far as I read it is bad practice to do it like this
if ($host ~* ^www\.) {
return 301 https://example.com$request_uri;
}
But, at least in this case I'm sure that it is only rewrite if WWW is present.