Forum Moderators: coopster
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();
}
?>
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?