Dan L
12-02-2005, 03:21 PM
<?php
$domain = $_SERVER['SERVER_NAME'];
$data = $_SERVER['REQUEST_URI'];
if(fnmatch('*.*.*',$domain)) {
$domain = explode('.',$domain);
$newDomain = $domain[1].'.'.$domain[2].'/'.$domain[0].$data;
header('Location: '.$newDomain);
} else {
echo 'Could not forward from this URL.';
}
?>
This script takes a subdomain such as 'subdomain.example.com/index.php?a=test' and transforms it into 'example.com/subdomain/index.php?a=test'
This is helpful is you want to have subdomains point to a folder on your main domain.
Note: This does not support TLDs such as '.co.uk', '.com.cn', or any TLDs with two parts.
$domain = $_SERVER['SERVER_NAME'];
$data = $_SERVER['REQUEST_URI'];
if(fnmatch('*.*.*',$domain)) {
$domain = explode('.',$domain);
$newDomain = $domain[1].'.'.$domain[2].'/'.$domain[0].$data;
header('Location: '.$newDomain);
} else {
echo 'Could not forward from this URL.';
}
?>
This script takes a subdomain such as 'subdomain.example.com/index.php?a=test' and transforms it into 'example.com/subdomain/index.php?a=test'
This is helpful is you want to have subdomains point to a folder on your main domain.
Note: This does not support TLDs such as '.co.uk', '.com.cn', or any TLDs with two parts.
