0

I have a domain pointer (eg. www.example.com) to a second domain (eg. www.example.es) and I would like to know from which domain I come from. Is it possible to do it with PHP?

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
jprog
  • 155
  • 1
  • 2
  • 12

2 Answers2

0

Try this $_SERVER["HTTP_REFERER"];

Vassilis Barzokas
  • 3,105
  • 2
  • 26
  • 41
  • If I print the $_SERVER variable, it doesn't return any HTTP_REFERER parameter, as the browser doesn't come from a previous url... (wich is the usage I've found for that parameter)... – jprog Jan 03 '13 at 11:29
  • Then your answer is here http://stackoverflow.com/questions/4043196/get-http-referrer-on-redirection So, you cant. – Vassilis Barzokas Jan 03 '13 at 11:40
0

Assuming that by a "domain pointer" you mean a DNS CNAME record pointing from one domain name to another, then to know which of the two domain names was actually used to access the site, look in:

$server = $_SERVER["SERVER_NAME"];
Alnitak
  • 334,560
  • 70
  • 407
  • 495
  • Thanks, but in my case $_SERVER["SERVER_NAME"] returns always the "redirected" domain, not the domain where I come from... – jprog Jan 03 '13 at 11:34
  • @jpris then you need to explain how this redirection is being done. If it's with an HTTP 30x style redirection then AFAIK you can't tell what the original domain name was unless the redirecting server adds an additional header (or URI parameter) to tell you what the original domain name was. – Alnitak Jan 03 '13 at 11:44
  • Finally I've found the problem. Your answer is right but my pointer settings where wrong, I had to check it (when I created it) to create it as an alias. Without doing that, it always returned the domain it pointed to. – jprog Jan 03 '13 at 12:01