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/(.*) http://foo.com/bar/$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 "dodo.foo.com" - then you modify the URL to add this hostname in front of the URL - only to strip it out again and redirect to "foo.com/bar/" with a proxy ruleGood 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 withRewriteCond %{HTTP_HOST} ^dodo\.foo\.com$ RewriteRule ^(.*) http://foo.com/bar/$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 possible2. major issue: form POST problem: form POST should probably not get redirected either, but so far I can't find what condition to test forConsidering 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> Servername foo.com DocumentRoot /var/www/foo.com/docs ... (anything belonging to foo.com) </VirtualHost> <VirtualHost *:80> Servername dodo.foo.com DocumentRoot /var/www/dodo.foo.com/docs (**) ... (anything belonging to dodo.foo.com) </VirtualHost> and just forget about redirecting/proxying from dodo.foo.com to foo.com/bar.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.
http://httpd.apache.org/docs/2.2/vhosts/ (**) if you really insist, this could be DocumentRoot /var/www/foo.com/docs/bar 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:http://httpd.apache.org/userslist.html> for more info. To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx " from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx