Seperate rules per virtual site

Topics: User Forum
Dec 1, 2006 at 9:40 PM
First, thank you on behalf of the University of Alaska Anchorage. As we move a major site from apache to IIS your tool has proven robust and invaluable. We are quite impressed and pleased.

I would like to have different rules per site. What is you recommended best practice for that?

I could do multiple install folders with copies of the DLL, but I worry about the extensions colliding.

I could do RewriteCond %{HTTP_HOST} in front of all my rules, but that is a little tedious for sysadmins. It could impact performance.

What do you recommend for having different rules for different sites hosted on the same physical server?
Dec 2, 2006 at 8:56 PM
Now, having added 1,000 lines worth of rules, I've decided that I do indeed want a separate file per virtual site. The main reason is that virtual sites using host headers half to be OR'ed into every rule for each virtual host.

Imagine a site with three names bookstore, uaabookstore, and bs. Each rule must include these values. Plus, every time a new host header is added to an IIS website ALL the rules for that host must be updated.

RewriteCond %{HTTP_HOST} "bookstore" OR
RewriteCond %{HTTP_HOST} "uaabookstore" OR
RewriteCond %{HTTP_HOST} "bs"
RewriteRule ^/books$ I,R=301
Dec 14, 2006 at 9:53 PM
hello Jim,
I'm glad you are getting value out of IIRF.

one thing:

instead of
RewriteCond %{HTTP_HOST} "bookstore" OR
RewriteCond %{HTTP_HOST} "uaabookstore" OR
RewriteCond %{HTTP_HOST} "bs"
RewriteRule ^/books$ I,R=301

maybe consider

RewriteCond %{HTTP_HOST} (bookstore|bs|uaabookstore)
RewriteRule ^/books$ I,R=301

You can "or" all the hostnames in one regular expression, using just one RewriteCond. It probably won't matter much for perf but it might be more readable in the ini file.