Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

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.

share|improve this answer
Yes, /sub1 is an application root but it doesn't help the ApplicationPath problem. For the time being, I changed the rule to redirect to sub1.example.com/sub1 instead of rewriting it. It's not pretty, but it works. –  jrummell Apr 23 '10 at 20:35
I'm not positive of the syntax right off but it's something like Request.ApplicationPath("~\") that will give you the path relative to the root of the application that you're currently in. –  Scott Forsyth - MVP Apr 26 '10 at 19:06
up vote 0 down vote accepted

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 to http://sub.example.com/sub/abc. It's not ideal, but it works. See my blog post for the details.

share|improve this answer
Thanks for this blog. I've been struggling with the same issue ever since WH4L sold-out and moved to a new platform offering less features than before so I was looking at WinHost. I'd ended up at the URL rewrite workaround for this but like you, I'm struggling to get Response.Redirect("~/MyPage.aspx") working –  Rob Nicholson May 18 '10 at 7:13

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.