The Problem
I'm attempting to make a mod_rewrite rule in Apache's global server configuration, and have it take effect for all Virtual Hosts. The documentation certainly indicates this is perfectly fine to do. However, I can't for the life of me get anything to actually rewrite. Even when using a mind-numbingly simple configuration like the following:
LoadModule rewrite_module modules/mod_rewrite.so
RewriteEngine On
RewriteRule .* https://www.google.com
However, if I move the above code into one of the virtual servers, it works just fine. (for that domain) But I'd like to have this entered into just the server config, and have it take effect for every hosted website. Is that actually possible? Am I missing some detail? Barring that, is there a good way to troubleshoot what might be going wrong?
Background:
I'm attempting to make a 503 maintenance page for use during system outages. Currently, I'm doing this via mod_alias and a RedirectMatch rule. RedirectMatch 503 ^((?!^(/error/503_error.html)|(/images/503_error.jpg)$).)*$
This lives just fine in the server config (httpd.conf), and applies to all Virtual Hosts when it's enabled.
I'm looking to replace this with mod_rewrite so I can exempt some internal IPs from the redirection. Essentially, so the system can be tested internally, without also making it available to everyone else.
Currently running fully up-to-date RHEL 5.10 with stock Apache 2.2.3.
By default, mod_rewrite config is an exception to the normal inheritance rules; virtual hosts don't inherit from the server config.
See the inheritance flags of RewriteOptions to get the behavior you want.