Question

Is there a way to have a RewriteRule fire on any domain that is requested on a box? For example, I have 5 VirtualHosts that would have the exact same RewriteRule applied to them and currently each VirtualHost directive has the rule, but can I put this somewhere 'global' so that upkeep is easier?

Was it helpful?

Solution

No, I'm afraid not

OTHER TIPS

You can, but it is somewhat of a hack. Create your RewriteRule in a .htaccess somewhere like:

/www/redirects/global/.htaccess

Now just set the DocumentRoot for your virtualhosts to /www/redirects/global/ and every request will be forced through your RewriteRule's.

I haven't tested it, but the mod_rewrite docs say that RewriteRule can be used in the server config context.

You may also want to look up how RewriteMaps work. Since these are a file, they could be considered to be a "global" source, but there are limitations on them since they are primarily static.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top