l_e,
One thing at a time!
Kad,
mod_rewrite is NOT a scripting language so it does not have convenient “group” notation to have RewriteCond statements applied to multiple RewriteRules. On the other hand, there is the Skip flag which tells mod_rewrite to SKIP (read GOTO) the next n RewriteRules (block statements).
NOW, I must agree with l_e that your mod_rewrite code could use some improvement:
RewriteCond %{HTTP_HOST} ^firstdomain\\.com [OR]
RewriteCond %{HTTP_HOST} ^seconddomain\\.com [OR]
RewriteCond %{HTTP_HOST} ^thirddomain\\.com
can be written as a single statement:
RewriteCond %{HTTP_HOST} ^(first|second|third)domain\\.com$ [NC]
The atom allowed ONE of the entries inside to be matched; no www? accommodated; the No Case flag is NECESSARY because domains are NOT case sensitive.
RewriteRule ^images/(.*)$ images/$1 [QSA,L]
Well, l_e has a point as this is clearly “loopy.” REALLY! (.*) is the most ABUSED bit of regex code that there is and you’ve fallen into that trap. My advice is to LEARN SOME REGEX!
RewriteRule ^dir1/(.*)$ index.php?dir=dir1/$1.php [QSA,L]
Despite my comment about (.*) above, it appears to be a correct usage (assuming that you mean to capture NOTHING or ANYTHING - a BAD idea, nonetheless).
RewriteRule ^(.*)/(.*)-search-(.*).html index.php?do=search&var1=$1&var2=$2&var3=$3 [QSA,L]
OMG! Three of them! If index.php can handle nothing to absolute garbage, it may actually work - but that’s (IMHO) horrible coding.
# Followed by rule that should not associated with the earlier RewriteCond's
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
If all else fails, send ANYTHING (not null) to index.php? That makes index.php your 404 script.
It’s not my job to interpret your intentions but I’ve got to agree with l_e’s inference that you need to brush up on your regex before creating mod_rewrite statements. My tutorial article will help you with your regex but, unless I updated rather recently, I don’t have an example of the Skip flag ([QSA,L,S=3] will tell mod_rewrite to append any existing query string, that this terminates the mod_rewrite block statement and to SKIP the next 3 RewriteRules - the answer to your question).
Regards,
DK