You can use gethostbynamefor this.
for example
$ip = "1.2.3.4";
$domain = "www.example.com";
if(gethostbyname($domain) == $ip) { echo 'IP/URL Match.'; }
gethostbyname ()
Edit:
Quentin noted that this does not mean that they will return to the correct website, which is correct. I misunderstood the beginning of the message. They will only go to the correct website if the default virtual host for the IP address points to the same document root as the URL.
2:
, , - , , , , , - , , .
, , , - $_SERVER['SERVER_NAME'] - .