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 10:34:47 GMT
Oliver Schoenborn wrote:
>>> 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]
>> 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
>> rule
> Good point. I'll have to see if I can combine them, I based those two rules on an example,
but I may be able to get away with 
> RewriteCond   %{HTTP_HOST}                 ^dodo\.foo\.com$
> RewriteRule   ^(.*)$1   [P]
> There are a couple other issues: 
> 1. minor performance issue: all CSS and javascript etc (which all start with /bar/ in
URL) do not need a redirect so I should probably filter those out if possible
> 2. major issue: form POST problem: form POST should probably not get redirected either,
but so far I can't find what condition to test for
>> Considering your latest answer, I am also now inclined to think that
>> using <VirtualHost> sections would be much cleaner.
> More efficient, more maintainable, or less code to write to obtain same effect?
Probably all of the above.
General idea :

Listen *:80
NameVirtualHost *:80

<VirtualHost *:80>
   DocumentRoot /var/www/

... (anything belonging to


<VirtualHost *:80>
   DocumentRoot /var/www/   (**)

... (anything belonging to


and just forget about redirecting/proxying from to

Now go read about Virtual Hosts.  That's what this stuff was created for 
: run 2 or more websites on the same Apache.  Your recently acquired 
knowledge about proxying and rewriting URLs will not be lost.  But maybe 
this is not the best place to use it.

(**) if you really insist, this could be
   DocumentRoot /var/www/
but I believe that this complicates the maintenance and programming.

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