mod_rewrite one rule works, second doesn't

I am really confused on this one.

Using mod_rewrite on Apache 1.3 for a while. I want to add a new rule and it does not seem to be inheriting a value from teh Rewrite Cond.

   RewriteEngine on
    RewriteCond     %{HTTP_HOST} ^([^.]+)\.mydomain\.com$ [NC]
    RewriteCond     %{REQUEST_URI} !^/lib/
    RewriteRule     ^/forums/(.*)$ /home/web/public_html/page1.php?country_dir=%1&path=$1 [QSA,L]
    RewriteRule     ^(.*)$ /home/web/public_html/page2.php?country_dir=%1&path=$1 [QSA,L]

My first rule will pass the sub_domain whenI use "%1", but the second one does not. Is there a trick to this? What am I missing?

T
LVL 2
td234Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

caterham_wwwCommented:
You must repeat the condition, because the condition is checked only after the RewriteRule was checked (and matched), so the cond. can apply only to the corresponding rule.

RewriteEngine on
RewriteCond     %{HTTP_HOST} ^([^.]+)\.mydomain\.com$ [NC]
# that condition seems to be useless. If you're restricting the rule to /forum/, the condition
# will never match against /lib/, because in the rule you already said it must start with /forum/
#RewriteCond     %{REQUEST_URI} !^/lib/
RewriteRule     ^/forums/(.*)$ /home/web/public_html/page1.php?country_dir=%1&path=$1 [QSA,L]
# may be the cond. is for that rule?
RewriteCond     %{REQUEST_URI} !^/lib/
RewriteCond     %{HTTP_HOST} ^([^.]+)\.mydomain\.com$ [NC]
RewriteRule     ^(.*)$ /home/web/public_html/page2.php?country_dir=%1&path=$1 [QSA,L]

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
td234Author Commented:
Excellent. That I had deduiced that and tried that, but got it to work from your example.

Thank you.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Apache Web Server

From novice to tech pro — start learning today.