httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From André Warnier>
Subject Re: [users@httpd] best way to modify a URL
Date Thu, 17 Dec 2009 09:34:53 GMT
Oliver Schoenborn wrote:
> In order to apply the proxying just for only, I use a rewrite rule. Here
is what I have so far, seems to work completely: 
> RewriteCond   %{HTTP_HOST}                 ^dodo\.foo\.com$
> RewriteRule   ^/bar/(.*)               /$1    [R,L]
> RewriteCond   %{HTTP_HOST}                 ^dodo\.foo\.com$
> RewriteRule   ^(.+)                        %{HTTP_HOST}$1          [C]
> RewriteRule   ^dodo\.foo\.com/(.*)$1   [P]
> The [R,L] of first rule causes a redirect to client and the rule processing ends so client
will just make a new request with the /bar/ stripped out, AND client browser will show the
redirected URL. The [P] in second rule will cause proxying, but only for requests to,
so client will NOT see that is really the URL used. Time will tell if there are
any corner cases that this doesn't cover. But boy, that rewrite module is powerful stuff!
The main aspect is that you understand what is going on.
Now you can fly with your own wings.
In the second part of my answer, I was trying to avoid doing an external 
redirect, because :
- it is less efficient in terms of bandwidth : you add a round-trip to 
the browser and back
- it is less efficient in terms of your server : you have to process 2 
consecutive requests, instead of just one
- even for a fleeting moment, the browser is aware of the redirection, 
while if you do the redirection entirely inside of Apache, the browser 
never sees anything, and thinks the whole time that it is talking to

Also, in your example above, for me instinctively the last 3 rules look 
like you are doing some extra work that should not be necessary :
- you test if the host name is ""
- then you modify the URL to add this hostname in front of the URL
- only to strip it out again and redirect to "" with a proxy 
It may all work, but it seems terribly heavy.
Maybe I'm wrong though.

Considering your latest answer, I am also now inclined to think that 
using <VirtualHost> sections would be much cleaner.

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