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

Example: Serve different files for different browsers

Scenario:

In this example, we assume that we have a rich web application that uses advanced web browser features, for example advanced MSIE and Firefox features. Those features are unique on each web browser, so we have to serve two different versions of our web application files. To achive this we will use "User-agent" HTTP header which contains the name of the requesting web browser. Also, we need to serve a third, plain, and featureless version of the web application for every other web browser.

Configuration:

#Turn IIS Mod-Rewrite engine on
RewriteEngine On

#Check if "User-agent" HTTP header contains MSIE...
RewriteCond %{HTTP_USER_AGENT} MSIE [NC]
#...and if so, add a "/msie" prefix to the URL
RewriteRule ^(.*)$ /msie$1 [L]

#Check if "User-agent" HTTP header contains Firefox...
RewriteCond %{HTTP_USER_AGENT} Firefox [NC]
#...and if so, add a "/firefox" prefix to the URL
RewriteRule ^(.*)$ /firefox$1 [L]

#Check if "User-agent" HTTP header contains neither MSIE nor Firefox...
RewriteCond %{HTTP_USER_AGENT} !MSIE|Firefox [NC]
#...and if so, add a "/plain" prefix to the URL
RewriteRule ^(.*)$ /plain$1 [L]

 
Download and try
IIS Mod-Rewrite
NOW!


IIS rewrite

Download IIS Mod-Rewrite

Purchase IIS Mod-Rewrite