Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have two domains ( and Both of them use the same Windows hosting server with IIS7.

One of the domains is being called the "primary domain" by my hosting provider (GoDaddy) and it always points to the root folder that I was given.

For the other domain, I have created a virtual directory in IIS and pointed it there.

The folder structure is like this -


So, if I type, I see the regulakr Default.aspx. But if I type, I am shown the contents of domain2folder as if it were a separate web application - I think that is what IIS virtual directory is meant for. Well and good.

But the problem is, when I type, I see the domain2's website!

But I don't want that to be shown when I use the path like that from domain1. Only if they use, user should be able to see those contents. How can I do that? Hope I am making sense.


share|improve this question

You can use URL Rewrite to prevent access based on the Host header or redirect to the right domain if desired:

If your site is running in IIS 7 or above and your hoster has it installed you can just drop a web.config in your domain2folder with the following contents, it will redirect to the right domain if anybody tries to access it using the wrong domain:

        <rule name="HostNameRule">
          <match url="(.*)" />
            <add input="{HTTP_HOST}" pattern="^domain2\.com$" negate="true" />
          <action type="Redirect" url="{R:1}" />
share|improve this answer

It seriously doesn't make sense to set it up this way.

You'd typically just set up domain2folder as the root of another web site.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.