File: D:/bin/iirf/ExampleIniFiles/RouteBasedOnHostname.ini
# RouteBasedOnHostname.ini
#
# Route based on hostname.
#
# Combines the use of server variables with the detection of
# files and directories, to do routing of requests.
#
#
# remember to rename this file to IsapiRewrite4.ini ,
# or copy this content to a file named IsapiRewrite4.ini
# before using it!
#
# Thu, 13 Jul 2006 15:11
#
RewriteLog c:\temp\iirfLog.out
RewriteLogLevel 5
# The next three non-blank and non-comment lines are a stanza.
# Two RewriteCond statements and an attached RewriteRule.
# This RewriteCond statement says - execute the attached RewriteRule
# if the SERVER_NAME used in the URL matches the specified pattern.
# In this case, "www.chiesa.net" will match, and "images.chiesa.net"
# will match, but www.chiesa.com will not match.
RewriteCond %{SERVER_NAME} ([^\.]+)\.chiesa\.net$ [I]
# This RewriteCond evaluates to true only if the specified directory
# does not exist. In this case the pattern to match for the directory is
# c:\Inetpub\wwwroot\XXXXX where XXXX is replaced by the most-recently
# matched pattern. In this case it is the enclosing parens in the above
# RewriteCond, which captures the host name. For example, "www" or "images".
# As a result the RewriteConf evaluates to true when c:\Inetpub\wwwroot\www or
# c:\Inetpub\wwwroot\images IS NOT a directory.
RewriteCond c:\Inetpub\wwwroot\%1 !-d
# If both the above statements are true (they are joined by a logical AND),
# then the Rule is executed. In this case it redirects to a URL "NotFound.htm."
# The flags attached to this rule say, U = set the HTTP_URL_REWRITE variable,
# I = case insensitive, and L = make this the last rule to process, if it
# evaluates to true. So, no more mapping of URLs after this.
RewriteRule ^(.*)$ /NotFound.htm [U,I,L]
# This stanza of rules is the converse. It rewrites if the directory
# in question DOES exist.
RewriteCond %{SERVER_NAME} ([^\.]+)\.chiesa\.net$ [I]
RewriteCond c:\Inetpub\wwwroot\%1 -d
RewriteRule ^(.*)$ /common/driver.aspx?url=$1&host=%1 [U,I,L]