Hosting multiple domains pointed to the same web-space

Place the snippet of code in an index.php file to pull up a different web page for each domain pointed to the same web-space.

<?
$serverName = $HTTP_HOST;
$serverName = str_replace("www.","",$serverName);
$serverName = str_replace(".com","",$serverName);
$serverName = str_replace(".net","",$serverName);
$serverName = str_replace(".org","",$serverName);
if (!(empty($serverName))) {
   include("./".$serverName.".html");
}
?>

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Serve domains from sub-folders

You can also serve domains pointed to the same server space to be directed to a particular sub-folder within the main hosting account using mod_rewrite rules:

Options +FollowSymLinks
RewriteEngine On                                                                            
RewriteBase /
RewriteCond %{HTTP_HOST} domain_name.tld [NC]
RewriteCond %{REQUEST_URI} !folder_name/
RewriteRule ^(.*)$ folder_name/$1 [L]

Comment