views:

69

answers:

1

I just recently migrated from a linux host to a dedicated server with windows 2003, I had only one site using Mod_rewrite, but with ISAPI _Rewrite 3 free, the rules are global.

How do I write a condition to affect only "mysite.com" and not the others?

this is my httpd.conf file

# Helicon ISAPI_Rewrite configuration file
# Version 3.1.0.66

RewriteEngine On
RewriteBase /
RewriteRule ^([A-Za-z0-9-]+)/?$ index.php?page=$1 
RewriteRule ^([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/?$ index.php?page=$1&id=$2 [L]

I dont want to buy ISAPI_Rewrite just for this one site

Thank you

+1  A: 

At least concerning Apache’s mod_rewrite, you could use the C flag to chain the rules like this:

RewriteCond %{HTTP_HOST} =example.com
RewriteRule ^ - [C]
RewriteRule ^([A-Za-z0-9-]+)/?$ index.php?page=$1 [C]
RewriteRule ^([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/?$ index.php?page=$1&id=$2 [L]

If one rule does not match, all following chained rules are skipped. That means, if the first rule does not match (host name is not example.com), the following chained rules are skipped. Note not to add the C flag to the last rule as the chain flag.

Gumbo
what's "RewriteRule ^ - [C]" for? I tried it didnt work but I think it has something to do with "RewrieBase /" or HTTP_HOST is not working somehow, thanks for answering btw
sergiogx
@zombiegx: I explained that in my answer: “[…] if the first rule does not match (host name is not `example.com`) […]”
Gumbo