I want to be able to redirect domains like to the same sub domain of We have a wildcard SSL for the domain *.whanganuionline.com but not the second level subdomains.
I have tried to use regex server_name directives to try and detect and act on those second level sub domains but they are not working. What happens is that Google Chrome will just display the www version of the domain and a full page warning complaining about the certificate being wrong. (Haven't tried other browsers but would expect the same result as I know my certificate doesn't cover the second level subdomain.)
server { listen 443 ssl; listen [::]:443 ssl; # ipv6only=on; server_name ~^www\.(?<newhost>.*)\.whanganuionline\.com ; return 302 } I am not sure if the redirect is not working because of a lack of SSL certificate on the second level subdomain even though its being redirected or for another reason or how do I even debug this? I have tried adding "debug" to the end of some error_log statements but I am not seeing anything useful.
Is my server block correct? How can I tell if its being invoked or not and will it work without a valid SSL certificate on the second level subdomain?
2 Reset to default