jrummell
jrummell

Reputation: 43087

How to manage sub-domains on WinHost with IIS7 URL Rewrite 2.0?

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?

Upvotes: 0

Views: 1486

Answers (3)

Arshi Shaikh
Arshi Shaikh

Reputation: 11

Altaf's article explained the resolution by removing the ~ sign. Look at the point 7 there.

Upvotes: 1

jrummell
jrummell

Reputation: 43087

I tried my luck on serverfault. No helpful answers there either, but I did post my solution:

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.

https://serverfault.com/questions/134125/how-to-manage-sub-domains-on-winhost-with-iis7-url-rewrite-2-0/135533#135533

Upvotes: 1

Related Questions