If http://www.my-domain.com/header/database.php is requested, in database.php $_SERVER['HTTP_HOST'] will contain "www.my-domain.com". It doesnt depend on the request url at all. it depends on the Host: header that is sent to apache sever on www.my-domain.com. php just captures the Host header and put it in HTTP_HOST variable. if you send a XXX header, php will put it in HTTP_XXX server variable. So it wont work for you.
However you can use $_SERVER['
REMOTE_ADDR']. It will contain 101.256.23.43. This is the IP of the domain that is requesting the URI on your server. But you can not detect which domain is requested. because connections are not created by domain. they are created by IP. Though you can use gethostbyaddr() type function to reverse the IP to domain mapping. that will only work if 101.256.23.43 has only one domain. But normally in shared hosting lots of domain is created by domain pointer. In that case gethostbyaddr() wont retrieve the correct domain name.
So you have to rely on IP address only.
Hope that helps.