Reputation: 2908
Is it possible to detect whether a user navigated to my site via Domain Name or by IP Address? Google isn't being very helpful.
Upvotes: 0
Views: 384
Reputation: 5269
Yes it is: In PHP you have the server-variables, and this one you need:
$_SERVER['HTTP_REFERER'];
This will give you the domain you visitor came from :)
Upvotes: 1
Reputation: 137290
Yes, you can eg. use client-side, in JavaScript (judging from the tags it is acceptable):
window.location.hostname
as per documentation: https://developer.mozilla.org/en-US/docs/DOM/window.location
Or server-side, in PHP:
$_SERVER['HTTP_HOST']
as per documentation: http://php.net/manual/en/reserved.variables.server.php
Upvotes: 2