1 package, multiple sites

Discussion in 'General troubleshooting' started by cityswift, Jul 5, 2009.

  1. I have 3 sites running from 1 DiscountASP.net account. This is the way they have been setup:

    domain.com/site1/htdocs/
    domain.com/site2/htdocs/
    domain.com/site3/htdocs/

    I have external domains that I need to point to these sites:

    site1.com -> domain.com/site1/htdocs/
    site2.com -> domain.com/site2/htdocs/
    site3.com -> domain.com/site3/htdocs/

    Does anybody know what I need to do to accommplish this?

    I configure the domain A records to the server's IP address, but how does the DASP server know where home directory is for each domain? Is this something to do with "domain pointers"?

    Any help would be much appreciated... :)
     
  2. The way that I achieve this type of functionality is by routing all requests to my external domains to my DASP web servers' application root using DNS A records managed at the domain registrar side. Then when the DASP root web application is hit, an IHttpModule that performs 301 redirection based on the requested domain takes over. There's no need for domain pointers if you do it this way and you can also rewrite the URL in the IHttpModule if you want to ;-)
     
  3. Thanks CrystalCMS - you've been incredibly helpful with my posts :)

    I must admit, I'm not overly familiar with IIS (I normally work with a LAMP stack). The server I'm using is running IIS 6.

    Do you know of an example of an IHttpModule that I could use to do this?

    Alternatively, I'm not too sure what a "domain pointer" is, but would it essenitally achieve the same thing?
     
  4. No problem. There may well be a standard generic way of writing code for an IHttpModule to cope with all redirect types and url rewrites in this scenario but when I came up against this issue I just steamed ahead and developed my own specialized version.

    What follows is a bit of backgrounder and I think you've already identified the requirements in some of what I've mentioned below;

    The core of the logic within a module like this, is that it needs to know based on the requested url domain, where to 301 redirect to because you will typically have multiple external domains that you want to redirect to multiple hosted sub-applications (3 in your example..that could grow to be more in time perhaps?). This means that this domain<->sub-application location configuration data does need to be stored somewhere - in a database, in your web.config, in some xml file..it's your choice but you do need to store this configuration data otherwise the logic will end up just hardcoded into the module or its' supporting classes - which obviously is not ideal. Also keep in mind that all requests will be routed through this module so I strongly recommend keeping the code in there as efficient as possible and certainly do implement server side caching on your configuration data.

    Anyway I'll attach the IHttpModule from my CrystalCMS content management system here so you can see what I've done - it is developed in C#. Some of the code is actually implemented in extension methods I've written on the inbound HttpRequest class and it's those methods that do the work to determine the external requested domain - this means that you won't see the full picture by looking at the one file I've attached here, but it should be enough to give you some ideas and get you started if you decide to go down this route.

    So far as domain pointers go, I'll let the DASP guys answer that question for you. You can also search on this forum to get an idea about that functionality for yourself and see what other users say and think.

    Personally I've never really seen the point in domain pointers (pun not intended ;-)) because no-one has yet convinced me of the benefits. If I can achieve the same functionality myself with acceptable performance, without having to shell out for another hosted service and also have full control over the results I'll probably always prefer that method anyway.
     

    Attached Files:

  5. I got lost reading this post.
    I have one website hosted with dasp
    I now wanted to host more sites, one for each business my brother is working on.
    is that kind of what this post is about?
     
  6. Yes it's possible to have multiple websites hosted by a single DASP account. I have a number of separate domains/websites hosted by my one DASP account; they are all served by a single CMS system I developed, but the principal would be the same for separate ASP.NET web applications.

    http://www.crystalcms.co.uk
    http://www.jjssoftware.co.uk
    http://www.littlemonstersphotography.co.uk
    + a few others

    The DASP requirement (or certainly the most flexible way to enable this functionality) is to add the IP/Subdomain bundle to your account and once you have this, you can write code to redirect ASP.NET applications as requests are made to your web server similar to the code attached to this thread. Your highest priority web site would remain at the root of the account so no redirect is performed for that application but you would perform 301 redirects for other sub-applications/web sites in your account.

    HTH
     

Share This Page