IIS Mod-Rewrite examples
Overview Documentation Download Purchase FAQ  
IIS Mod-Rewrite - URL rewrite tool for IIS

Example: Deny access to a list of hosts

Scenario:

In this example, we want to deny access of a list of hosts to a specific location (http://www.domain.com/restricted). To achieve this we will check the "REMOTE_HOST" variable against a list of hosts.

Configuration:

Map Text:
#BadHostList.txt
badhost1 deny
badhost2 deny
badhost3 deny
badhost4 deny
badhost5 deny


Configuration text:
#Turn IIS Mod-Rewrite engine on
RewriteEngine On

#Load map with random webserver names
RewriteMap BadHostList txt:x:\path\BadHostList.txt

#Check if the client host is contained in BadHostList Map...
RewriteCond ${BadHostList:%{REMOTE_HOST}} =deny [NC,OR]
RewriteCond ${BadHostList:%{REMOTE_ADDR}} =deny [NC]
#...and if so, send a "Forbidden" HTTP header for every URL targeting location "/restricted/"
RewriteRule ^/restricted/(.*)$ - [F]
 
Download and try
IIS Mod-Rewrite
NOW!


IIS rewrite

Download IIS Mod-Rewrite

Purchase IIS Mod-Rewrite