Question

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

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top