Announcement

Collapse
No announcement yet.

Simulating Host Headers

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Simulating Host Headers

    I am in charge of moving 3 main web sites into one larger grouped web site. (due to some organization changes etc.)

    However - what we want to do is push people to a different "home page" depending on their desired destination. I other words:

    www.xyz.com -> /htdocs/index.htm
    www.anotherplace.com -> /htdocs/anotherplace/index.htm

    etc.

    I hear this referred to as "host headers" (e.g. IIS)

    The host we have does not support host headers, but will allow up to 10 different domains to point to our server. What we need to do on the main page is pick out where they are destined and send them to a separate location.

    This is probably not real pretty.. but it would work for us until we find a larger host or other solution.

    I thought maybe someone might know how to do this with .php code?

    Thanks!
    www.morcmtb.org

  • #2
    The hostname requested *should* be stored in the php global variable $_SERVER['HTTP_HOST'] as something like "www.xyz.com"
    PHP Code:
    switch ($_SERVER['HTTP_HOST']) {
        case 
    'www.xyz.com':
            
    header('Location: http://www.yourhost.com/xyz/index.htm');
            break;
        
    // add more
     
        
    default:
            
    header('Location: http://www.yourhost.com/yourdefaultpage.html');

    This is the only way I know of to do this. If your site host is running a web server so old, it's not HTTP 1.1 compliant, then you'd better find another hosting provider fast!
    Last edited by TeKnIcIaN; Fri 7th Feb '03, 11:25am.

    Comment


    • #3
      i believe it should be header('Location: ...');

      Comment


      • #4
        Originally posted by Cyborg from DH
        i believe it should be header('Location: ...');
        oops... I got frustrated by the wysywig editor and the auto-parsing of URLs inside the PHP code. Think I'll go post a bug report about that one, hehehe

        Comment

        widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
        Working...
        X