Sunday, April 17, 2011

Subdomain to point to subdirectory of main site?

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

From stackoverflow
  • 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 : dude, rtfm. I gave you enough to get started :)
  • Using ISAPI Rewrite

    [ISAPI_Rewrite]
    
    RewriteCond  Host:  (?:www\.)?other\.com
    RewriteRule  (.*)   http://www.domain.com/other$1 [I,L]
    
    vartec : Well, actually you're in luck. IIS7 does indeed provide similar functionality. http://learn.iis.net/page.aspx/460/using-url-rewrite-module/
  • 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 : good point...it would not inherit the config files. There would need to be some in the "other" directory.

0 comments:

Post a Comment