配置apache url过滤正则表达式匹配

ProxyPassMatch Directive
Description: Maps remote servers into the local server URL-space using regular expressions

Syntax: ProxyPassMatch [regex] !|url [key=value [key=value …]]

Context: server config, virtual host, directory

Status: Extension

Module: mod_proxy

Compatibility: available in Apache 2.2.5 and later

This directive is equivalent to ProxyPass but makes use of regular expressions instead of simple prefix matching. The supplied regular expression is matched against the url, and if it matches, the server will substitute any parenthesized matches into the given string and use it as a new url.
Suppose the local server has address http://example.com/; then
ProxyPassMatch ^(/.*\.gif)$ http://backend.example.com$1

will cause a local request for http://example.com/foo/bar.gif to be internally converted into a proxy request to http://backend.example.com/foo/bar.gif.
Note

The URL argument must be parsable as a URL before regexp substitutions (as well as after). This limits the matches you can use. For instance, if we had used

ProxyPassMatch ^(/.*\.gif)$ http://backend.example.com:8000$1

in our previous example, it would fail with a syntax error at server startup. This is a bug (PR 46665 in the ASF bugzilla), and the workaround is to reformulate the match:

ProxyPassMatch ^/(.*\.gif)$ http://backend.example.com:8000/$1

The ! directive is useful in situations where you don’t want to reverse-proxy a subdirectory.
例子