Forum Moderators: coopster

Message Too Old, No Replies

Domain Redirect

One Host/Two Domains/Two Sites

         

sspfireman

4:02 am on Jan 19, 2006 (gmt 0)



First, I'm new to PHP . . . Second, I've searched for this,but can't seem to find what I'm trying to do.

I have a new domain that I would like to temporarily host in a directory of another site I already have running. Is there a PHP script that will direct a user depending on what url they enter, i.e. www.domain1.com takes them to www.domain1.com/main.php and www.domain2.com takes them to a subdirectory of domain1 or www.domain1.com/dir/index.html?

I've tried the script below as default.php that directs depending on domain entered, but I'm not sure if it will even work and I get a parse error on line 4:

<?php
$host = $_SERVER["HTTP_HOST"];

switch ($host) {

        case 'www.domain1.com':
                header("Location: http://www.domain1.com/main.php");
                exit();

        case 'domain1.com':
                header("Location: http://www.domain1.com/main.php");
                exit();

case 'www.domain2.com':
                header("Location: http://www.domain1.com/dir/index.html");
                exit();

case 'domain2.com':
                header("Location: http://www.domain1.com/dir/index.html");
                exit();

        default:
                header("Location: http://www.domain1.com/main.php");
                exit();

                }
?>

grandpa

9:04 am on Jan 19, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Hi sspfireman and Welcome to WebmasterWorld, and to the world of PHP.

I think its more typical to set up your DNS records for the new site. Your host should be able to assist you with setting up a sub-domain.

I'm not familiar with case syntax, you might want to double check that. What is the error you're getting?