Last active
March 25, 2021 08:49
-
-
Save uWayLu/243d4681f1e43b18e73ccfa30ceffda0 to your computer and use it in GitHub Desktop.
resovle CNAME to orig hostname
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$hostname = $_SERVER['HTTP_HOST']; | |
$get_hostname_orig = function (&$hostname) use (&$get_hostname_orig) { | |
$record = dns_get_record($hostname, DNS_CNAME); | |
if (count($record) > 0) { | |
$hostname = $record[0]['target']; | |
$get_hostname_orig($hostname); | |
} | |
}; | |
$get_hostname_orig($hostname); | |
echo $hostname; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment