Question

I understand how using a full domain with an A record works ($_SERVER['SERVER_NAME']), but when using a subdomain with bit.ly, they ask for it to point to cname.bit.ly - why dont subdomains just get pointed to the same IP address as normal domains and is there a difference in determining the referring sub-domain?

Was it helpful?

Solution

there is no difference having a hostname either as cname or A-Record. $_SERVER['SERVER_NAME'] has nothing to do with that. Cname is not a http-redirect.

If you want to determine the host (as requested by the user via http/1.1) which was requested in using your script, use $_SERVBER['HTTP_HOST]

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top