PHP - dynamic page via subdomain
- by Phil Jackson
Hi, im creating profile pages based on a subdomains using the wildcard DNS setting.
Problem being, if the subdomain is incorrect, I want it to redirect to the same page but without the subdomain infront ie;
if ( preg_match('/^(www\.)?([^.]+)\.domainname\.co.uk$/', $_SERVER['HTTP_HOST'], $match)) {
$DISPLAY_NAME = $match[2];
$query = "SELECT * FROM `" . ACCOUNT_TABLE . "` WHERE DISPLAY_NAME = '$DISPLAY_NAME' AND ACCOUNT_TYPE = 'premium_account'";
$q = mysql_query( $query, $CON ) or die( "_error_" . mysql_error() );
if( mysql_num_rows( $q ) != 0 ) {
}else{
mysql_close( $CON );
header("location: http://www.domainname.co.uk");
exit;
}
}
I get a browser error: Firefox has detected that the server is redirecting the request for this address in a way that will never complete.
I think its because when using header("location: http://www.domainname.co.uk"); it still puts the sub domain infront i.e. ; header("location: http://www.sub.domainname.co.uk");
Does anyone know how to sort this and/or what is the problem.
Regards,
Phil