Knowledgebase: Domain Names / DNS
How to make a sub-domain point to a sub-directory using ISAP_Rewrite.
Posted by Joe Rebis (Import) on 14 June 2010 01:16 PM

Using ISAPI rewrite to point a sub-domain to a sub-directory:

You must have a dedicated IP for this method to work correctly.

After adding an "A" record for the sub-domain in the DNS zone for the primary domain you can use ISAPI_Rewrite 2 to rewrite sub-domain URLs so they point to a sub-directory without it showing in the URL. You can repeat the rules to add additional sub-sites. If you create a file called httpd.ini (using notepad) and put it in your WWWROOT folder for the website with the sub-domains you can add the following code to create a rule for it to point to a sub-directory off the website. You can duplicate the second part of the rule to add more as needed. If you plan to install a web application (e.g. DotNetNuke or WordPress), you will want to create a Virtual Directory on the website pointing to the same folder so IIS will enable it for applications. Note, we will be upgrading to the latest version of the URL rewriting tool sometime soon. Please pay close attention to make sure this rule will be compatible with the new version.

[ISAPI_Rewrite]

#Rules used to emulate a website in a sub-directory (old sub-domain way).

#Rename this file httpd.ini and place in the main website WWWROOT folder.

#Fix missing slash char on folders.

RewriteCond Host: (.*)

RewriteRule ([^.?]+[^.?/]) http\://$1$2/ [I,R]

#Emulate an additional website.

RewriteCond Host: (?:sub-domain\.)?your-domain\.com

RewriteRule (.*) /your-sub-dirdectory$1 [I,L]

**Please Note** Replace 'sub-domain' and 'your-domain' with your website.

We don't guarantee this method will work 100% of the time and in 100% of situations.

(169 vote(s))
Helpful
Not helpful

Comments (0)
Post a new comment
 
 
Full Name:
Email:
Comments:
CAPTCHA Verification 
 
Please enter the text you see in the image into the textbox below (we use this to prevent automated submissions).

Copyright © 2015 EPhost, Inc. All rights reserved.