ISAPI Rewrite
page 1 of 1
Published: 28 Dec 2004
Unedited - Community Contributed
Have you ever wanted to manage multiple domain names under a single account in IIS (Internet Information Services)?
by Web Team at ORCS Web
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 14029/ 12

Have you ever wanted to manage multiple domain names under a single account in IIS (Internet Information Services)? A common way to do this is to handle it from code. There are some disadvantages when handling this directly from code. Static pages aren't redirected, non-developers will need to purchase or dust off their programming books, and evidence remains that a redirection was done.

Along came ISAPI Rewrite to solve this issue. Running at the ISAPI level in IIS, this is done before any page or code is accessed so it works equally well on static and dynamic content. It overcomes all the objections mentioned above.

With common redirection code, the user would see something like this:

With the ISAPI Rewrite component, the user will see this:

Even though behind the scenes the sites can be in completely different sub-folders, the person visiting the website won't have any concept of this. They will simply see the clean domain names.

ISAPI Rewrite will rewrite (kind of like a redirect) the user to a sub-folder even though the web browser doesn't realize this.

This is done very fast and efficiently and managed by a file called httpd.ini which should be placed in the root of the site. It controls which domain names are handled by which sub-folder by utilizing different regular expression rules.

Some tips to remember when creating the rules.

# is used to comment out a line

The following characters must be preceded by a "\" to be recognized as a literal character ( meaning a character that represents itself)

".", "*", "?", "+", "(", ")", "{", "}", "[", "]", "^" and "$".
This becomes important when typing ( it would have to look like (www\.domain\.com)

Parentheses are used to group items together to be marked as what is to be matched, such as "(apple)*" would match all of the string "appleappleapple".

You can see more helpful expression tips here,

Some examples of the rules you will see in the httpd.ini file look like this:

  #manual redirect of one domain
#RewriteCond  Host:  (www\.)?domain1\.com
#RewriteRule  (.*)   /domain1$2

#redirecting to another URL
#RewriteCond  Host:  (www\.)?domain1\.com
#RewriteRule  (.+)  http\://www\.domain2\.com$1 [R]

#Rewrite just one domain but keep the old link working
#RewriteCond  Host:  (www\.)?domain1\.com
#RewriteRule  (?!/domain1)(.*)   /domain1$2 [I]

Many tricks come with a catch, and this is no exception. One disadvantage that I have come across is that the response.write from ASP or ASP.NET does not work well in conjunction with this component. Absolute paths are required since relative paths are done after ISAPI Rewrite handles the request and aren't redirected as would be expected. The workaround is to use absolute paths with the full domain name in the redirect. If Server.Transfer is to be used, it should be tested as well. It runs into similar issues.

Additionally, when using ASP or ASP.NET, the new virtual root folder should be marked as an application so that the new virtual root's folder is used for global.asa(x), web.config and /bin.

ORCS Web offers this to all clients for a one-time setup of $25. We'll place a sample httpd.ini in the root folder of your site and assign the ISAPI dll to your site. While we don't claim to be experts on regular expressions and various advanced sceneries, we have included the most common examples in the httpd.ini file. The vendor has a great newsgroup available if desired and answer even the most difficult questions.

Other considerations to keep in mind is that all the statistics will be shared under a single domain. Email is also shared so if you plan to manage an email account with this, let us know and we'll assist you with the best solution.

by Pam Dean, Web Support Specialist with ORCS Web, Inc. - a company that provides managed hosting services for clients who develop and deploy their applications on Microsoft Windows platforms.

User Comments

Title: NIKE NFL jerseys   
Name: NIKE NFL jerseys
Date: 2012-07-02 10:09:31 AM
We are professional jerseys manufacturer from china, nike nfl jerseys, mlb jerseys, nhl jerseys,nba jerseys and shoes
,heap jerseys,2012 nike nfl Jerseys,nba jersey and shorts,oklahoma city thunder jersey,official jeremy lin new york knicks jersey,NFL Jerseys Wholesale,blake griffin jersey blue,NFL jerseys For Sale online.All Our Jerseys Are Sewn On and Directly From Chinese Jerseys Factory
,Wholesale cheap jerseys,Cheap mlb jerseys,]Nike NFL Jerseys,Cheap China Wholesae,Wholesale jerseys From China,2012 nike nfl Jerseys,Jerseys From China,,2012 nike nfl Jerseys,Revolution 30 nba jerseys,jersey of nba chicago bulls direk rose ,nfl jerseys,green bay packers jerseys wholesale,Buffalo Bills nike nfl jerseys sale,good supplier soccer jerseys,cool base mlb jerseys,Revolution 30 nba jerseys,2012 stanley cup nhl jersey,
We are professional jerseys manufacturer from china, nike nfl jerseys, mlb jerseys, nhl jerseys,nba jerseys and shoes.
Title: soluções em ti   
Name: soluções em ti
Date: 2011-03-09 1:11:04 PM
gread post! helped a lot this post, I had to use on my site!
Title: What if...   
Name: hvor grøn
Date: 2010-01-06 3:04:40 AM
What if there is no "www." in front of the domain?
Name: Robert Baindourov
Date: 2009-06-23 5:58:13 PM
I there, I need help with ISAPI rewrite light. I dont understand how to use the 'RewriteBase /' equivalent. An engineer told me I needed that .htaccess file in order to get my this site working. But I own a WAMP system with IIS, and haven't been able to get it going. Please take a look at the site.
Title: Isapi Rewrite working not in all browsers   
Name: Connie
Date: 2007-10-19 9:43:25 PM
Title: To Luciano   
Name: Pam Dean
Date: 2007-01-26 12:45:09 PM

I would suggest using the ISAPI Rewrite Forums. They are very experienced and respond quickly. I'm not certain what code would work best for you, but they will know right away.


Pam Dean
Title: ISAPI Rewrite   
Name: Pam Dean
Date: 2007-01-26 12:42:37 PM
The httpd.ini file is usually in the IsapiRewrite folder when it is downloaded/installed. You should go to the ISAPI Filters tab of your website and enter in the a Filter Name of 'ISAPI Rewrite' and point to the dll. After that the httpd.ini file will do all the work if you have code in it.


Pam Dean
Title: To Luciano   
Name: Hanan
Date: 2007-01-22 8:41:26 AM
First, I can't find the httpd.ini file. Where does it reside :) ?
Second thing, If I put the rule in this file, does that mean I need nothing to configure with the "ISAPI REWRITE" tab in the Properties window for my website? So all what I need to do is to create an httpd.ini file ???

Last thing, Luciano, I am very interested in your question, and I want to make the same thing. Have you found a solution?
Title: Can you help me ?   
Name: Luciano
Date: 2007-01-08 12:57:23 PM
Yes, i have the opinioes directory.

For example:

I want to be so:
or maybe

Anyone can help me with this ?
Title: Can you help me ?   
Name: Pam
Date: 2006-11-06 5:46:41 PM
Luciano, Do you have the opinioes directory set to be an application?

Title: Can you help me ?   
Name: Luciano
Date: 2006-11-06 11:42:58 AM
I have one site in asp host, but i can't make the rewrite rules work.

THis is my httpd.ini

RewriteEngine on
RewriteRule ^/opinioes/(.*).asp /opinioes/estado.asp?ide=$2&estado=$1

This is that we want to have with this:

Can you help me ?
Title: To Tracy   
Name: Pam Dean
Date: 2006-03-25 3:42:56 PM
Thanks, I'm glad you found it informative. What are you trying to make work? Maybe I can help?

Title: ISAPI Rewrite   
Name: Tracy
Date: 2006-03-25 2:54:48 PM
I am trying to find a way to make it work ...I tried their free version..I could not make it work...
btw thanks for the very informative article..

SEO Expert

Product Spotlight
Product Spotlight 

Community Advice: ASP | SQL | XML | Regular Expressions | Windows

©Copyright 1998-2024  |  Page Processed at 2024-06-15 3:28:50 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search