I have a web server. Lots and lots of DNS entries for domains and subdomains are pointing at this server. Most of them, like www.foo.com, foo.com, and subdomain.foo.com, I want to keep. However, there is a certain list of subdomains for which I want to redirect.
For example, all of these urls resolve to the web server.
test.foo.com bar.foo.com baz.foo.com
test.foo.com is fine, we don't have to do anything, but bar and baz are on the list. That means we have to redirect them to
bar.list.foo.com baz.list.foo.com
I can't just do a subdomain wild-card rewrite here because there is a long list of subdomains we want to redirect and a long list of ones we do not want to redirect.
Can/should I do a mod_rewrite that compares the subdomain to a list in a text file? If so, how do I do that? If not, how do I handle these redirects?
I know that I can make an entry into a mod_rewrite configuration, one for each subdomain, but that is a lot of typing, and there must be a better answer.
You could use the RewriteMap directive to provide a list of subdomains (or other keys) that you can use inside rewrite rules.