0
                                                              #www.   domain .   tld
RewriteCond     %{HTTP_HOST}                                (?:.*\.)?([^.]+)\.(?:[^.]+)$
RewriteCond     /home/%1/                                   -d
RewriteRule     ^(.+)                                       %{HTTP_HOST}$1
RewriteRule     (?:.*\.)?([^.]+)\.(?:[^.]+)/media/(.*)$    /home/$1/client/media/$2 [L] 
RewriteRule     (?:.*\.)?([^.]+)\.(?:[^.]+)/(.*)$          /home/$1/www/$2 [L] 

Here is rewritelog output:

#(4) RewriteCond: input='tfnoo.mydomain.org' pattern='(?:.*\.)?([^.]+)\.(?:[^.]+)$' [NC] => matched
#(4) RewriteCond: input='/home/mydomain/' pattern='-d'
=> not-matched
#(3) applying pattern '(?:.*\.)?([^.]+)\.(?:[^.]+)/media/(.*)$' to uri 'http://www.mydomain.org/files/images/logo.png'
#(3) applying pattern '(?:.*\.)?([^.]+)\.(?:[^.]+)/(.*)$' to uri 'http://www.mydomain.org/files/images/logo.png'
#(2) rewrite 'http://www.mydomain.org/files/images/logo.png'
-> '/home/mydomain/www/logo.png'

If you note on the 2nd 4 it failed the -d (if directory exists) pattern. Which is correct. mydomain does not have a /home/. Therefore it should never rewrite, atleast according to my understanding that all rewriterules are subject to rewriteconds as logical ANDs.

ParoX
  • 302
  • 1
  • 6
  • 21

1 Answers1

0

No, only the rule that immediately follows one or more RewriteCond directives is included. That is:

                                                          #www.   domain .   tld
RewriteCond     %{HTTP_HOST}                                (?:.*\.)?([^.]+)\.(?:[^.]+)$
RewriteCond     /home/%1/                                   -d
# This will only be run if the two conditions above, are met
RewriteRule     ^(.+)                                       %{HTTP_HOST}$1

# These will always be run!
RewriteRule     (?:.*\.)?([^.]+)\.(?:[^.]+)/media/(.*)$    /home/$1/client/media/$2 [L] 
RewriteRule     (?:.*\.)?([^.]+)\.(?:[^.]+)/(.*)$          /home/$1/www/$2 [L] 

If you notice in your log, it skips the first RewriteRule, but doesn't even check conditions for the other two.

Andrew M.
  • 10,982
  • 2
  • 34
  • 29
  • Arggg. Why don't they come up with a simple if/else normal language for this type of thing. – ParoX Jan 02 '11 at 06:05