I have two domains (domain1.com and domain2.com). 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 -
root/
--Default.aspx
--SomeFile.aspx
--domain2folder/
----Default.aspx
----Domain2SomeFile.aspx
So, if I type domain1.com, I see the regulakr Default.aspx. But if I type domain2.com, 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 http://domain1.com/domain2folder, 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 domain2.com, user should be able to see those contents. How can I do that? Hope I am making sense.
Thanks.
You can use URL Rewrite to prevent access based on the Host header or redirect to the right domain if desired: http://www.iis.net/download/URLRewrite
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:
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.