note 43351 added to function.header

From: Date: Fri, 18 Jun 2004 09:23:26 +0000
Subject: note 43351 added to function.header
Groups: php.notes 
Request: Send a blank email to php-notes+get-71284@lists.php.net to get a copy of this message
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. ---- Manual Page -- http://www.php.net/manual/en/function.header.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+43351 Delete -- http://master.php.net/manage/user-notes.php?action=delete+43351&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+43351&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#71284) next »