httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Vincent Bray" <>
Subject Re: [users@httpd] Rewrite Rule using HTTP Header information
Date Wed, 11 Jul 2007 04:08:38 GMT
On 11/07/07, Paul Kuykendall <> wrote:
> I am trying to get a rewrite rule working that will take the value
> from an HTTP header and use the value to create a new target
> destination for the HTTP request.  An example of what I'm trying to do
> follows:
> Original HTTP request being sent to http://myhost.domain/ containing the header
> This needs to be rewritten and sent to http://myhost.domain/SOME_VALUE
> This will then be forwarded using a reverse proxy to
> http://apphost.domain/SomeLocation/SomeApplication

I don't understand this part. How can you forward one url to another?

> I know that this may seem like a really convoluted way of doing
> things, but our clients don't actually know where they are sending
> requests to, other than the server name.  The receiving server has to
> pass the request along based on the routing ID; however, the routing
> ID isn't actually part of the final destination URL.  The routing ID
> -> destination URL mapping will be generated and included as an
> external config file loaded into the Apache configuration at load.
> So far what I have is the following:
> LoadModule proxy_module modules/
> LoadModule proxy_http_module modules/
> ProxyRequests Off
> ProxyPass /SOME_VALUE http://apphost.domain/SomeLocation/SomeApplication
> <Location /SOME_VALUE>
>     ProxyPassReverse /SomeLocation/SomeApplication
> </Location>
> LoadModule rewrite_module modules/
> RewriteEngine On
> RewriteCond %{HTTP:MyRoutingID} (.*)
> RewriteRule .* - [E=ROUTING_ID:$1]
> RewriteRule ^/(.*) http://myhost.domain/%{ROUTING_ID} [P,L]
> The proxy config is working fine.  The RewriteRule however, does not.
> Thanks for any help on getting the RewriteRule working.

These two parts of your config do different and conflicting things.
Are you expecting the rewrite to the address containing the ROUTING_ID
to be then forwarded by your ProxyPass? If so, why the double
indirection? In any case there's a few errors in the rule, this might
work better.

LoadModule rewrite_module modules/
RewriteEngine On
RewriteCond %{HTTP:MyRoutingID} (.*)
# Not that captures from conditions are reading using %n rather than $n
RewriteRule ^/(.*) http://myhost.domain/%1 [P,L]


The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:> for more info.
To unsubscribe, e-mail:
   "   from the digest:
For additional commands, e-mail:

View raw message