Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've a situation where I want to redirect everything that starts with /app to an internal server. Basically the idea is that Apache will work as a reverse proxy doing the following conversion:

http://external/app -> http://myserver:1082/myapp

I was able to do it using Rewrite, as follows:

  RewriteCond %{REQUEST_URI} ^/app
  RewriteRule ^/app(.*)$ http://myserver:1082/myapp$1 [L,P]

  ProxyPassReverse /app http://myserver:1082/myapp

It works fine. The issue is that now I'm gonna have a language preffix on the URL, but no on the application. So I need the following redirection:

http://external/app -> http://myserver:1082/myapp
http://external/en/app -> http://myserver:1082/myapp
http://external/pt/app -> http://myserver:1082/myapp

While this can be done with the rewrite, I have a problem with the proxyPassReverse. Because basically I need to do a dynamic ProxyPassRever that, depending on the actual URL request by the user, changes the Location

ProxyPassReverse /en/app http://myserver:1082/myapp
ProxyPassReverse /pt/app http://myserver:1082/myapp
ProxyPassReverse /app http://myserver:1082/myapp

It would be something like

ProxyPassReverse ${preffix}/app http://myserver:1082/myapp

Is it possible to do that?

share|improve this question

From ProxyPathReverse:

When used inside a section, the first argument is omitted and the local directory is obtained from the .

From Location:

The URL may use wildcards. In a wild-card string, ? matches any single character, and * matches any sequences of characters. Extended regular expressions can also be used, with the addition of the ~ character.

So you should be able to use:

<Location /[a-z]+/app>
    ProxyPathReverse http://myserver:1082/myapp
share|improve this answer
Actually, that does not work, since it replaces "myserver:1082/myapp"; for the literal string "/[a-z]+", instead of using the actual path that matched the regular expression – Jose L Martinez-Avial Jul 7 '12 at 16:38
Where does it do this replacement? – Pierre Carrier Jul 7 '12 at 17:04
On the affected headers on the response. – Jose L Martinez-Avial Jul 7 '12 at 17:19

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.