I host a website on DiscountASP.NET and they have any option of adding a domain pointer for a separate domain using your same hosting account. Thus if the original site is abc.com you can purchase a domain pointer to xyz.com and both initially point to the same root location. Using the root for abc.com is OK, but when xyz.com is the address, I want to reroute to a separate subdirectory that contains the code for xyz.com. Where would I try redirecting xyz.com to reference the subdirectory's code instead of using the root directory? I am thinking that handling it the Global.asax where typically all the routing code resides is too late, since I want each site's Global.asax file to handle their respective sites independently.
A post on the DiscountAsp.Net forum for classic ASP discussed adding code like the following to the default document.
If InStr( UCase(Request.ServerVariables("SERVER_NAME")), UCase("subdomain1.YourHostedDomainName.com") ) > 0 Then Response.Redirect("/subdomain1") ElseIf InStr( UCase(Request.ServerVariables("SERVER_NAME")), UCase("subdomain2.YourHostedDomainName.com") ) > 0 Then Response.Redirect("/subdomain2") ElseIf InStr( UCase(Request.ServerVariables("SERVER_NAME")), UCase("subdomain3.YourHostedDomainName.com") ) > 0 Then Response.Redirect("/subdomain3/home.asp") End If
ASP.NET MVC is my first web project and as far I what I understand all routing flows through RegisterRoutes() and the route collection which is set of in Global.asax. Any ideas?