Skip to content

Instantly share code, notes, and snippets.

@uWayLu
Last active March 25, 2021 08:49
Show Gist options
  • Save uWayLu/243d4681f1e43b18e73ccfa30ceffda0 to your computer and use it in GitHub Desktop.
Save uWayLu/243d4681f1e43b18e73ccfa30ceffda0 to your computer and use it in GitHub Desktop.
resovle CNAME to orig hostname
<?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