I'm trying out WinHost and I'm running into some issues with sub-domains. On WinHost, you can have multiple sub-domains per hosting account, but each sub-domain points to the root website. E.g. you can have www.example.com, sub1.example.com, and sub2.example.com but all of them display the content at http://www.example.com/.
Other Hosts allow you to point sub-domains to a sub folder in your website. This would allow you to point sub1.example.com to /sub1, sub2.example.com to /sub2 and www.example.com to /.
WinHost recommends using an asp/aspx page to redirect http://sub1.example.com to http://sub1.example.com/sub1, which points to /sub1. While that would work, I'd like to not have the subdomain in the url twice.
So I tried using IIS7 URL Rewrite to point http://sub1.example.com to /sub1. Ben Powell describes this in detail on his blog. This is great, except Request.ApplicationPath is now /sub1/path/to/current/page.aspx, which breaks ASP.Net Themes (and probably other stuff too).
What can I do to fix the ApplicationPath? Is there a better way to accomplish this?
In addition to the redirect, you will need to mark each site as an application in IIS. WinHost should have a control panel or way for you to mark each of the sites as their own application. That will make folders like /sub1/ as a root application.
I couldn't figure out how to fix the application path, so now I'm simply using the URL Rewrite Module to redirect (not rewrite) from
http://sub.example.com/abc
tohttp://sub.example.com/sub/abc
. It's not ideal, but it works. See my blog post for the details.