My hoster directly resolves *.mydomain.tld
to my server, whitout having to setup subdomains manually. This nicely allows me to add subdomains using virtual hosts. Now the problem with that is that also subdomains that i don't need will resolve to that server. I'd like to handle that using a temporary redirect (in case i add a subdomain, permanent doesn't seem sensible):
<VirtualHost _default_:80>
# note: going to http would redirect to https anyways, so directly going https here
Redirect / https://www.mydomain.tld
</VirtualHost>
So far so easy, works fine. Now let's do the same on https.
<VirtualHost _default_:443>
Redirect / https://www.mydomain.tld
</VirtualHost>
That does not work, because ofc i do not have a wildcard certificate (using letsencrypt), so any browser accessing i.e. https://foo.mydomain.tld
will complain about not being able to make a secure connection before the redirect would be sent.
Is there any other way around this i'm missing here? I also tried using RewriteEngine
, but with the same result, as the header would only be sent after the secure connection has been made.
If that is not possible, would it be sensible to just throw away the default conf? What would happen with non-configured domains in that case?