Quote:
|
Originally Posted by DanX
As far as I know, that would only match .*.* extensions, not .*
|
Yes, that is correct, it will only support .co.uk and not .com for example.
Also considering peoples main subdomain is usually www you can code it like this for support of both types of TLD's
PHP Code:
$domain = $_SERVER['SERVER_NAME'];
$data = $_SERVER['REQUEST_URI'];
$domain = explode('.',$domain);
if($domain[0] != 'www')
{
$newDomain = 'http://www.'.$domain[1].'.'.$domain[2].($domain[3] ? '.'.$domain[3] : '').'/'.$domain[0].$data;
header('Location: '.$newDomain);
echo("You are being redirected to <A HREF=\"{$newDomain}\">{$newDomain}</A>");
exit();
}
//continue page output
This will only work if you use www to access the root of your site.