views:

906

answers:

3

I have my website running at:

www.example.com

I also have this other domain:

www.example.net

Is it possible to point "www.example.net" to a subdirectory of "www.example.com"? For example:

www.example.net-> www.example.com/other

?

It's not just a redirect, I need to serve the pages and see "www.example.net" in the user's browser.

What do you think?

We use IIS7 and everything is ASP.NET (aspx pages, ascx controls, etc).

A: 

You're looking at two methods for this:

  • URL rewriter
  • Server.Execute method

The first is a httpmodule that silently redirects the request without changing the url in the address bar, the second is a method you can call within aspx code. I think the latter is only good though if you're working in the same application, so I would go with the URL rewriter.

There is an official iis7 URL rewriter available on www.iis.net afaik.

-Oisin

x0n
Thanks, but can URL rewrite work across different applications in IIS7? How should I set up this in IIS? I create a new application for www.other.com , and set the URL rewrite there?
dude, rtfm. I gave you enough to get started :)
x0n
A: 

Using ISAPI Rewrite

[ISAPI_Rewrite]

RewriteCond  Host:  (?:www\.)?other\.com
RewriteRule  (.*)   http://www.domain.com/other$1 [I,L]
vartec
vartec, can the same be accomplished with IIS7 only, or a free alternative?
Well, actually you're in luck. IIS7 does indeed provide similar functionality. http://learn.iis.net/page.aspx/460/using-url-rewrite-module/
vartec
A: 

Two questions for you:

  1. Can you set them up as two different web sites in IIS?
  2. If someone visited example.net/page.htm, would that be the same as example.com/other/page.htm?

If the answer is yes to both of those, why not just setup a new web site in IIS and point it to the "other" file path.

Micky McQuade
Both answers are yes. Would it inherit web.config and other configuration from the "main"/root site? Or I'd need to keep other config files inside /other for this?
good point...it would not inherit the config files. There would need to be some in the "other" directory.
Micky McQuade
Thanks. There's another limitation to this, as our controls are stored in main website /controls folder. If I point the "other" domain to /other, and reference controls at /controls, it won't find it - I've just tested and it says something like "Parser Error, file could not be found".