The general rule is that the order of the directives is important. The directive that comes first and matches wins (just like the order of the
VirtualHost definitions – the first VHost is the default VHost).
In most cases it should work fine if you define
RewriteRules first and proxy rules like
ProxyPass last if you want to let redirection take place before your proxy settings apply.
Aliases and Redirects occurring in different contexts are processed
like other directives according to standard merging
when multiple Aliases or Redirects occur in the same context (for
example, in the same
section) they are processed in a particular order.
First, all Redirects are processed before Aliases are processed, and
therefore a request that matches a
will never have Aliases applied. Second, the Aliases and Redirects are
processed in the order they appear in the configuration files, with
the first match taking precedence.
For this reason, when two or more of these directives apply to the
same sub-path, you must list the most specific path first in order for
all the directives to have an effect.
RewriteRule directive is the real rewriting workhorse. The
directive can occur more than once, with each instance defining a
single rewrite rule. The order in which these rules are defined is
important - this is the order in which they will be applied at
Also see: Apache mod_rewrite Technical Details
Ordering ProxyPass Directives
ProxyPassMatch rules are checked in the order of configuration. The
first rule that matches wins. So usually you should sort conflicting
ProxyPass rules starting with the longest URLs first. Otherwise, later
rules for longer URLS will be hidden by any earlier rule which uses a
leading substring of the URL. Note that there is some relation with
Ordering ProxyPass Directives in Locations
ProxyPass directive can be placed in a
Location block, and the most specific
location will take precedence.
Exclusions and the no-proxy environment variable
Exclusions must come before the general
ProxyPass directives. In 2.4.26 and later,
the "no-proxy" environment variable is an alternative to exclusions,
and is the only way to configure an exclusion of a
Location context. This variable should be set with
SetEnv is not evaluated early enough.