Apache configuration redirect using only redirect, not rewrite
The reason to use Redirect
instead of mod_rewrite
is that the latter takes a lot more resources than the former - and the reason for this is that the latter can do a lot more things. One of the things that mod_rewrite
can do and RedirectMatch
can't is to keep track of the hostname used in the request.
So, the problem here is that you want to keep using the same domain name after the redirect, and you want all domains as aliases within the same virtual host. As long as you want both these things, then mod_rewrite
is the only tool.
If you could either redirect all requests to one canonical hostname, or you could split them up into one VirtualHost
per domain name, it would be possible to use RedirectMatch
instead, like so:
RedirectMatch ^(.*)$ https://dev.domain.com$1