Question

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).

Was it helpful?

Solution

Using ISAPI Rewrite

[ISAPI_Rewrite]

RewriteCond  Host:  (?:www\.)?other\.com
RewriteRule  (.*)   http://www.domain.com/other$1 [I,L]

OTHER TIPS

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

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top