Hi guys,
Thank you very much for valuable replies.. Really appreciate it.
I kind of don’t have permission to the server so I end up doing things in PHP.
I have a small problem. I will briefly explain my situation.
I checked the sub-domain using $_SERVER['HTTP_HOST'] and then validated that against my database values. If the value does not exist then Ii displayed the normal index page where as if the value exists I register a session and wanted to generate a PHP 404 error.
I have an .htaccess file in my root that catches all the 404 errors and redirect every call to a specific file.
I’m using a .htaccess file because I don’t want to change the URL that user typed since I wanted to feel them, that they are in a sub domain.(but actually they are not)
But the problem is even though I have generated the 404 error the .htaccess file won’t pick it up.
This is how I did it,
$domainname='';
$subdomainname='';
$domainarray = explode('.', $_SERVER['HTTP_HOST']);
$index=count($domainarray)-1;
$domainname= $domainarray[$index-1].".".$domainarray[$index];
for($i=0;$i<$index-1;$i++)
{
if($subdomainname=="")
{
$subdomainname=$domainarray[$i];
}
else
{
$subdomainname=$subdomainname.".".$domainarray[$i];
}
}
if($subdomainname<>'')
{
$sql = "SELECT id FROM tablename WHERE screenName='".$subdomainname."'";
$row = mysql_query($sql) or die ("Error checking screen name");
if(mysql_num_rows($row)<>0)
{
$result = mysql_fetch_array($row) or die ("Error getting screen name");
$_SESSION['bpId']=$result['id'];
$templateBPId=$result['id'];
header("HTTP/1.1 404 Not Found");
die();
}
}
What I’m doing wrong here?
Thanks,
Niroshan