문제

I am using ASP.NET 4.0 (integrated pipeline) with multiple domains in one hosting account. I have my primary domain set up but I want to separate the domains clearly using folder hiearchy. (I have root FTP access, can map all the domains but the master domain to subfolders) I need to map my master domain to a folder too. I'm sure ASP.NET does provide such functionality, probably in web.config settings, but I don't know how to do it. All my searches have led to PHP/Apache settings but I couldn't find one about ASP.NET remapping seamlessly.

For example, I've got these sites in my FTP root: /sites/abc.com

/sites/anothersite

/sites/xyz.com

/sites/mymastersite.com

I need to put to my root / a web.config that needs to map all requests to mymastersite.com to /sites/mymastersite.com folder, including all the subdomains too, seamlessly.

도움이 되었습니까?

해결책

I think that the correct solution is that every request by IIS go direct to the correct site, and not on the root as you say.

How ever a way that I can think to make what you ask is to use on Global.asax the Application_BeginRequest to RewritePath to the final destination and still have the link without the /site/ path.

protected void Application_BeginRequest(Object sender, EventArgs e)
{   
    if(HttpContext.Current.Request.Host.EndsWith("xyz.com"))
       RewritePath("/sites/xyz.com" + HttpContext.Current.Request.Path, false);  
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top