« Previous Next »

Thread: Wildcard host header support

Last post 10-05-2009 12:39 PM by TCost. 19 replies.

Average Rating Rate It (5)

RSS

Page 2 of 2 (20 items) < Previous 1 2

Sort Posts:

  • 02-04-2008, 9:49 PM In reply to

    • lmeyers
    • Not Ranked
    • Joined on 09-26-2003, 12:30 PM
    • SF
    • Posts 1

    Re: Wildcard host header support

    We are hosting a couple instances of DNN each with multiple portals. Each instance is setup on distinct IP as default web site. We let DNN figure out which portal to serve up based upon the subdomain(s)--DNN supports multiple aliases per portal. We also use the host file to create internal shortcut mappings to specific IP and again let DNN work out the intended portal site using alias.

    MicrosSoftware
  • 05-27-2009, 5:42 AM In reply to

    • kipusoep
    • Not Ranked
    • Joined on 03-23-2009, 11:49 AM
    • The Netherlands
    • Posts 7

    Re: Wildcard host header support

    I really do not understand why this feature / must-have is still being dropped... Come on, it shouldn't be that much work for the IIS team, right? But it would help A LOT...

    Greets, kipusoep
  • 07-09-2009, 12:06 PM In reply to

    Re: Wildcard host header support

    I've read about this online, as I want to do a simliar thing.

    The problem with the "IP" solution is it will only work for one site, on one IIS install, AND someone could register a dodgy domain name and point it to your IP and they'd get your website.

    What I have come up with (and waiting on the tests to confirm) is a workaround using ISAPI_Rewrite (which I suspect some of you are using anyway and have a .htaccess file with rules).

    Now, my solution is to put a .htaccess file in the root folder of the Default website, something like (might need some tweaking):

    RewriteEngine on

    RewriteCond %{HTTPS} (on)?
    RewriteCond %{HTTP_HOST} ^(?!(?:www))([^.]+)\.([^.]+\.[^.]+)$ [NC]
    RewriteRule ^([^.]+)?$ http(?%1s)://www.%3/(?1$1) [NC,P,QSA]

    Now, not forgetting your * DNS A record. What will happen is a user goes to whatever.mydomain.com and it will go to the IIS server, fail to find a match Host Header wise and will instead return the default website ("Under Construction" page), except with that .htaccess file and ISAPI-Rewrite it won't display the "Under Construction" page, as it will run this rule in the .htaccess file and instead pull in the equivalent from www.mydomain.com where more than likely you will have your actual .htaccess file in the root of your www website and where now you can not only specify rules for your www.domain.com but anything.yourdomain.com

    Most commonly you'll want something that does http://username.mydomain.com to pull in data from www.mydomain.com/users.php?user=username for example.

    If you don't have a .htaccess file with rules, then you'll just get your www.mydomain.com website but as subdomain.mydomain.com instead.

    Of course if you own the server (VPS or dedicated) you can tweak this "main" rule even more, but that was a generic one I hope shared hosting IIS companies could incorporate. Perhaps with a tagline of "Dynamic Subdomains".

  • 07-21-2009, 10:53 AM In reply to

    Re: Wildcard host header support

    I'm now using this rule:

    RewriteEngine on

    # subdomains subdomain.domain.com to www.domain.com for futher processing

    RewriteCond %{HTTPS} (on)?
    RewriteCond %{HTTP_HOST} ^(?!www\.)[^.]+\.([^.]+\.[^.]{2,3}(?:\.[^.]{2,3})?)$ [NC]
    RewriteRule (.*) http(?%1s)://www.%2/$1 [P,NC,QSA]

    and I'm using $_SERVER['HTTP_X_FORWARDED_HOST'] in my php page, which returns subdomain.mydomain.com you can of course then trim this down to just subdomain for use in your code.

    I'm waiting on my host to apply it to a .htaccess file in the Default Website.

  • 10-05-2009, 12:39 PM In reply to

    • TCost
    • Not Ranked
    • Joined on 10-05-2009, 12:16 PM
    • Posts 1

    Re: Wildcard host header support

    I just wanted to add my support for this feature as well.  It is going to become a larger and larger issue as more sites offer increased personalization options.  Many, if not most, of the DNS providers allow for easy DNS wild cards.  It is a shame that you then get stuck with hacks on the IIS side.

    Fortunately I only have one site that requires wild card sub-domains so far, so I'm good for now.  However, I fear the second site that needs this is only a couple months away so I'll need a new solution very soon.

Page 2 of 2 (20 items) < Previous 1 2
Microsoft Communities