treehouse : what would you like to learn today?
Web Design Web Development iOS Development

PHP redirect dependent on domain

  • I got a GoDaddy hosting account, the economy plan to save money. But you can only add domains to point to the root. How would I create a php script that would for example go:

    IF domain is "phpmyadmin.com" GOTO "../php"
    IF domain is "somatelse.com" GOTO "../som"

    Any ideas?
  • I've had a go at this myself. This will work correctly, right?


    <?php
    if( $_SERVER['HTTP_HOST'] == 'www.new.co.uk') {
    header( 'Location: ../new' );
    } elseif( $_SERVER['HTTP_HOST'] == 'www.old.co.uk') {
    header( 'Location: ../old' );
    }
    ?>