note 43351 deleted from function.header by kennyt

From: Date: Sun, 18 Jul 2004 18:02:39 +0000
Subject: note 43351 deleted from function.header by kennyt
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-73547@lists.php.net to get a copy of this message
Note Submitter: sam AT firestormltd DOT co DOT uk ---- I have two domains pointing to my personal webserver, and as they are free they have limited options. I wanted each to go to a different subdirectory; my code was as as follows: <?php $servername=$_SERVER['HTTP_HOST']; if ($servername == "www.example.net") { header("Location: /subdir1/"); exit; }elseif ($servername == "example.net") { header("Location: http://www.example.net"); exit; } elseif ($servername == "www.example.com" || $servername == "example.com") { header("Location: /subdir2"); exit; } else { header("Location: /subdir2/"); exit; } ?> This has to come before anything else in the script, including HTML. Note that one part of the code redirects to www. if it is not specified. Hope someone finds this useful.

« previous php.notes (#73547) next »