Zend - The PHP Company




Utilities

Add Code


php domain park  

Type: application
Added by: sfmoe
Entered: 22/02/2005
Last modified: 02/12/2004
Rating: - (fewer than 3 votes)
Views: 3622
it allows you to use the domains parked on your hosting company by rederecting to a file or directory you specify a la virtualhost its uefull if you can only host one domain name but have several parked under your account. in this example the code sends it to a main.html if the default host is used and sends it to thehostused.html otherwise


<?
//setup the host domain without www or .com .org .net or whatever it is //
$mainhost "whatever";
//this makes an array out of the url //
$hostvar explode("."$_SERVER['HTTP_HOST']);
//if statement that works around the use of www or not //
if($hostvar[0] == "www")
{
//another type of if statement this one checks to see if the mainhost is the domain used and sends it to the main page otherwise to whatever host.html
$hostvar[1]==$mainhostheader ("Location: http://www.".$mainhost.".com/main.html") : header ("Location: http://www.".$hostvar[1].".com/".$hostvar[1].".html");
}
//this is just in case they dont use a trailing www
elseif($hostvar[0] != "www")
{
//another type of if statement this one checks to see if the mainhost is the domain used and sends it to the main page otherwise to whatever host.html
$hostvar[0]==$mainhostheader ("Location: http://www.".$mainhost.".com/main.html") : header ("Location: http://www.".$hostvar[0].".com/".$hostvar[0].".html");
}
?> 


Usage Example




Rate This Script





Search



This Category All Categories