Flattr this

I've just started trialling Winhost.com. I've been with Webhost4life.com for 4 years now but there are a few things that have started to get on my nerves, so I've decided to try out some of the other big ASP.NET hosting specialist companies out there. Winhost.com offers a month-by-month contract, so I can get out any time (we'll see how easy that is in the future) so I didn't feel too bad about trying it out.


The first thing that struck me was that Winhost.com don't allow you to host multiple domains (or sub domains) as individual websites under one account. Essentially you have one IIS7 Website per account. This is something you can do on Webhost4life.com, and was one of the main reasons I went with them in the first place. I'm a web application developer, which means I want to be able to run numerous websites under one hosting account. It seems that this is a challenge to get for free in a Windows hosting environment.

My aim is to do the following (S: is the account root path):

  • http://www.mydomain.com/ => S:\MyRoot\Main
  • http://sub1.mydomain.com/ => S:\MyRoot\Sub1
  • http://sub2.mydomain.com/ => s:\MyRoot\Sub2

What I don't want (which is what Winhost.com suggest) is to end up with:

  • http://www.mydomain.com/main/default.aspx
  • http://sub1.mydomain.com/sub1/default.aspx
  • http://sub2.mydomain.com/sub2/default.aspx

Because, face it, that looks like shit.

So, we'll turn to IIS7's Url Rewrite feature to get this working. First of all configure your "Application Starting Points" from your Winhost.com Site Manager. You'll need four of them:

  • /
  • /Main
  • /Sub1
  • /Sub2

Now login via FTP and create a new web.config file in the root ("/") directory. Paste the following code in:

   1:  <?xml version="1.0" encoding="UTF-8"?>
   2:   
   3:  <configuration>
   4:   
   5:  <system.webServer>
   6:  <modules runAllManagedModulesForAllRequests="true" />
   7:  <rewrite>
   8:    <rules>
   9:      <rule name="Rewrite to folder1" stopProcessing="true">
  10:        <match url="(.*)" />
  11:        <conditions>
  12:          <add input="{HTTP_HOST}" pattern="^www.mydomain.com$" />
  13:        </conditions>
  14:        <action type="Rewrite" url="main/{R:1}" />
  15:      </rule>
  16:      <rule name="Rewrite to folder2" stopProcessing="true">
  17:        <match url="(.*)" />
  18:        <conditions>
  19:          <add input="{HTTP_HOST}" pattern="^sub1.mydomain.com$" />
  20:        </conditions>
  21:        <action type="Rewrite" url="sub1/{R:1}" />
  22:      </rule>
  23:      <rule name="Rewrite to folder3" stopProcessing="true">
  24:        <match url="(.*)" />
  25:        <conditions>
  26:          <add input="{HTTP_HOST}" pattern="^sub2.mydomain.com$" />
  27:        </conditions>
  28:        <action type="Rewrite" url="sub2/{R:1}" />
  29:      </rule>
  30:    </rules>
  31:  </rewrite>
  32:   
  33:  </system.webServer> 
  34:   
  35:  </configuration>

You can remove any other files from the root folder (i.e. "/").

This should also work on DiscountASP.net, as they appear to have a very similar set up.


22 comments:

Anonymous said...

Hi Ben,

FYI, I just moved (still moving some sites) to WinHost from WH4L this week too -- more than a few things bothered me about the 'new team' and the changes (unannounced) by WH4L in a lot of areas.

As a historial perspective I was with WH4L a bit longer than you -- and WH4L originally did NOT allow you to host multiple domains (or sub domains) as individual websites under one account when I first started with them -- that was a later change.

Maybe we can get WinHost to change at some point.

Thanks for your article. I'm just starting with IIS7, so the info helps.

David

Ben said...

Hi David,

Thanks for your comments. Have you been transferred to the new hosting environment with WH4L yet? I'm still waiting....

The jury is out on Winhost.com for the moment. The server response times certainly appear better than WH4L at the moment. I was hoping that WH4L might reduce the number of clients per server on the new environment they are rolling out.

Ben

David said...

Hey Ben,

They tried, and failed, to convert me to the new platform.

I do both .NET and some PHP/MySQL work.

The MS SQL databases weren't transferred at all -- apparently they have instituded a naming convention which my DB didn't match, but I was able to do a backup/restore to create it with a new name (required non-alpha character).

Also, ALL databases on the server were exposed, not access, but all the DB names were out in the open -- I finally got them to close that security hole -- I think it took them 4 days.

The MySQL databases were transferred, BUT...
1) There no longer is extenal access to the MySQL DBs, so no using the MySQL Admin/Query tools -- only their internal phpAdmin, or write a script, was their response.
2) The DBs were converted (without any indication) to MyISAM from InnoDB -- apparently InnoDB tables are no longer supported -- but that means no foreign keys or transactional support -- a deal breaker.

Also, after I got them to 'force' me over to the new platform -- which took them 3 tries over 2 days -- (I wanted to see what happened before my clients are converted) 4 of my 5 sites didn't work because they are ASP.NET MVC and (yes, my transfer left me still on Win2003/IIS 6) they didn't have the isapi mappings right. I told them 3 times what they needed to do -- the same as what was done on the old platform -- and after 4 days of it not being done, I moved to WinHost.

Their new support team is not very knowledgeable, and mostly you get back canned responses.

Oh, and should I mention how crappy the 'new' email is?

But what I really like is that the forum is 'under construction' -- I suspect they had to close it to keep the general customer population in the dark about how bad the experience is.

I've been in IT a lot of years from developer to CTO, as a consultant, project manager, etc.
Finally went back to development so I could 'work in the US' but live sunny Mexico.

This has all the ear-marks of either a bad PM, or management not supporting the PM as needed, but that doesn't really matter -- the net effects on the customer still stink.

Maybe the majority of customers will be converted fine, but those with any complexity in their websites best be prepared for the worst.

It appears the transition process has a lot of holes, little reporting available (no audit trail) to the customer on what technically occurred during the conversion for review (e.g., myIsam to InnoDB), little recourse to correct transition errors, and staff that is not adequately trained to deal with the problems when they do occur.

Other than that -- no problems.

David

Ben said...

Notably, although ActionLinks appear to still work, I have product paging that breaks, because it seems to look at the underlying path via Route.GetVirtualPath Method. This returns the path of "/sub1/sub1/" which causes 404s. I'm also using Elmah, and that has the same issue when I apply the rewrite rule above.

The options as I see them, are: a) to override the Route.GetVirtualPath method using a custom route (I spent a few hours on this last night to no avail and a migraine to boot), or b) to cough up for another hosting account with Winhost, or c) move elsewhere that supports multiple sites per hosting account. Option b) would be expensive, because I want to host a lot of sites.

In my case each application is essentially the same, but different domains load different product data. I can get around this for the moment by re-architecting the application to pass a "SiteId". However, that doesn't help everyone.

Please let me know if the script above helps or not. If you had problems with MVC apps, and manage to solve them, then please feel free to share the solution!

Adrian Grigore said...

Hi Ben,

Thanks for this interesting article. I've only just begun hosting my site at discountASP.net, before that I was only using linux hosting environments.

One thing that struck me is that their web servers seem to have very inconsistent performance (between 200 ms and 5 seconds response time for the same, trial request). I've ascertained that it is not a database or network speed problem. It rather seems to be a slow web server, probably affected by other apps running on the same machine. I've also tried ASPHostDirectory, but that was even worse. I never had such problems when using Perl / LAMP...

Since you also mentioned discountASP in your article and seem to have tried at least 3 ASP.NET hosts now, I'd like to know if you have had similar experiences. In your opinion, is shared hosting with ASP.NET suitable for creating fast database-driven website?

Ben said...

Hi Adrian. I haven't hosted with DiscountASP before so I can't really comment. However, it appears that DiscountASP and Winhost have a very similar setup, which is why I made the comment above that it would probably work on DiscountASP servers.

On a separate note I'm starting to be really tempted by VPS and Windows Azure to be honest. If Windows Azure had an extended free trial I might try and switch. The expression "you pay peanuts, you get monkeys" is rather apt with regards to web hosting.

I've not got much experience with LAMP, but the Ruby on Rails stuff looks really interesting and the hosting is way cheaper!

Grüße aus Bremen!

Anonymous said...

My migration was so bad I also am leaving webhost4life immediately. I was considering winhost and I'm glad I found this page since the subdomain problem is a showstopper for me.

Ben said...

@anonymous Remember though that you may run into issues with resolving internal Urls using this technique. You might still need to tweak your code for this to work. The Webhost4life solution for multiple sites under one account is way better, but it also costs $15 per pointer per year.

Anonymous said...

You rock! This worked great on my WinHost account. The only change I had to do was taking out the subdirectory, this was needed because post-backs where calling the sub from the sub (nesting the directory calls). Example:

<rule name="sub1.mydomain.com" stopProcessing="true">
<match url="(sub1.mydomain.com\/)*(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="^sub1.mydomain.com$" />
</conditions>
<action type="Rewrite" url="sub1.mydomain.com/{R:2}" />
</rule>

Peace

Rob Nicholson said...

Check out http://webhost4lifecustomers.ning.com/ where lots of unhappy WH4L customers hang out.

I assume that WH4L are trying to get II7 URL re-writing working?

Cheers, Rob.

Rob Nicholson said...

Quick question on this - do these sub-domains run as separate ASP.NET applications? For example, do they have separate application events like Application_Start etc?

Cheers, Rob.

Ben said...

I'm not sure but I think so. To be honest I haven't tried it. I think you will have problems rewriting sub.domain.com/sub1/default.aspx to sub.domain.com/default.aspx, because ASP.NET struggles to derive the virtual path. You'll end up with links such as sub.domain.com/sub/sub/default.aspx. I'll be interested to know if anyone has any success. I think that the answer to your question is yes, however, i think that they are setup as virtual directories (i.e. their own application space) but the web.config a the root will be inherited. WH4L (old) had better subdomain management than Winhost.

I haven't found another Windows shared hoster that offers proper multiple sites with domain pointers for free. You always need to pay for a separate site.

I ended up using Umbraco, that supports multiple domains in the root folder. Now I just have domain pointers all going to the root, and Umbraco takes care of the content for the multiple domains under one site.

The only way you are going to get true multi-site, multi-application, multi-domain is to pay for VPS.

Ben said...

@Rob Nicholson: Also check out what Anonymous said above. They seemed to get the multiple apps working on Winhost.com using a tweak to my original rewrite rule.

Rob Nicholson said...

@Ben: thanks for the reply. I hit the problem with sub.domain.com/sub/sub/default.aspx as well and solved it with another rule to not do URL redirection when there was a sub.domain.com/sub in there but I'll check out the other solution as well as that appears neater.

What a lot of faffing about as I call it :-)

Cheers, Rob.

Jeroen said...

I am, or should I say was, considering winhost for hosting several of my sites. But since running multiple (sub)domains & sites as seperate apps is not supported I'm going to look for another host. For those who want proper seperation as well, I found the following thread on the winhost forum: http://forum.winhost.com/showthread.php?t=3218&highlight=multiple. Taken from this thread: "...you can have multiple domain names...Now, bear in mind that you are using the same applicaiton pool. So if one site crashes, it will crash all the sites within that same application pool."

So, sad to say, no winhost for me.

Ben said...

@Jeroen. Let us all know if you find something better!

Donn Edwards said...

If you use Arvixe.com you don't need to do anything special. It keeps each web site separate by default, much the same way that the old WH4L servers did. In addition you can specify the version of the .NET framework for each site individually, which means you aren't forced to upgrade all your sites to version 4 if version 2 still works.

Bradley said...

Thanks for the info! I just switched to Winhost and am happy so far with their service.

The subdomain issue has proved difficult, but using the rewrite above seems to take care of most of the problems.

I do run into this problem however. When I assign a value to a link dynamically:
lnkDetail.NavigateUrl = "PropertyDetail.aspx?PropertyID=" + PropertyID.ToString();
it ends up including the subdomain folder into the address (eg: http://drv.balansolutions.com/drv/PropertyDetail.aspx instead of http://drv.balansolutions.com/PropertyDetail.aspx).

It also does this on post backs when I use gridviews/listviews and try to edit a row.

Any ideas? Thanks, Bradley

Bradley said...

I still run into a problem with post backs and links running server-side adding the subdomain folder too.

e.g. post back sends to "sub.domain.com/sub" instead of "sub.domain.com"

I'm assuming this is because the application path is set to the subdomain's folder. Any way to fix this?

Ben said...

Hi Bradley, see my comment above regarding a Route.GetVirtualPath override. I couldn't get this to work, but I'm sure that this is the way forward. Let us all know if you solve it!

Anonymous said...

This was awesome, I was about to move away from winhost in order to get the rewrite url to work. I also used snippets from this blog http://john.rummell.info/john/blog/post/WinHost-Sub-Domains-and-IIS-7-URL-Rewrite.aspx

my problem was that I have on hosting account and 1 ip.

I have about 10 different domains and needed to redirect to each domain without showing the subfolders that winhost makes me create for each site

www.mysite.com/site1

with your code I was able to rewrite all my sites to show just the URL.

now all my sites show:

www.mysites.com
www.zyx.com

important part of the code that I needed to add was



to keep sytle references working

thanks.

ahmet sali said...

thanks, this really helped me:)

Post a Comment

Copyright © 2008 - Ben Powell - is proudly powered by Blogger
Smashing Magazine - Design Disease - Blog and Web - Dilectio Blogger Template