HTTP
|
|
|
|
<? //===============================\
// Author:Patrick Loven \
// Name: Sub-Domain Redirect \
// Date: 11/09/01 \
// Site: www.lovenresources.com \
//===============================\
/*------------------------------------------------------------------------\
There are 2 ways of doing this, static and dynamic(for those few fortunate
enough to allow wildcard sub-domians). In either case, your isp must allow
sub-domains, and add them for you.
Static - This is setup to pass the user directly to the folder you want
based on the pre in the pre.domain.ltd. If criteria is passed, they will
be forwarded to the specified folder.
i.e. : search.domain.com => search.domain.com/search/
Dynamic - This is setup to pass the user to a dynamic "pre named folder"(i.e
users/whatever_dynamic),based on the pre in the pre.domain.ltd. If criteria
is passed, they will be forwarded to the specified folder.
i.e. : whatever.domain.com => domain.com/users/whatever/
whatever2.domain.com => domain.com/users/whatever2/
//------------------------------------------------------------------------*/
$where = explode(".",$HTTP_HOST); $default = ("yourstartpage.xxx");
/* Static
if($where[0] == "whatever1"){
header("Location:http://$HTTP_HOST/whatever1/");
}elseif($where[0] == "whatever2"){
header("Location:http://$HTTP_HOST/whatever2/");
}else{
header("Location:http://$HTTP_HOST/$default");
}
*/
// Dynamic if(is_dir("$DOCUMENT_ROOT/$where[0]")){
header("Location:http://$HTTP_HOST/$where[0]");
}else{
header("Location:http//$HTTP_HOST/$default");
} ?>
|
|
|
Usage Example
|
|
|
Rate This Script
|
|
|
|