Zend - The PHP Company




Utilities

Add Code


Gary Carr  

Type: code fragment
Added by: gcarrweb
Entered: 04/05/2005
Last modified: 02/12/2005
Rating: - (fewer than 3 votes)
Views: 2696
Handle multiple domains on a single user web directory space.


<?php
/*
This script allows multiple domain names to reside on a single user webspace. Your ISP must allow multiple domain names to point to your account for this to work. Also, you must handle all the work in the 'domainname.php' files, this file only  works if it is called, if another file is called directly it will not work. You must create a file for each domain that is in the hostnames array.

For example : if you have 3 domains (google, yahoo,msn) then you must have 3 php files like (google.php, yahoo.php, msn.php).

This script simply includes those files, so all the sites function must be included in those files.

*/

# domain names without www,com,org,net,tv (etc)//
$hostnames = array("google","yahoo");

# make url array
$hostvar explode("."$_SERVER['HTTP_HOST']);

# set default hostvar index
$idx=1;
for (
$z 0$z count($hostnames);$z++) {
    if (
$hostvar[0]==$hostnames[$z] || $hostvar[1]==$hostnames[$z]) {
        
# if a match was found include that file and exit
        
include_once($hostnames[$z].".php");
        exit;
    }
}
# if no match was found do nothing
?>


Usage Example




Rate This Script





Search



This Category All Categories