使用DNS支持在PHP中获取当前URL

For example, I have a PHP script located at https://somesite.com/script.php, but there's a DNS entry sitewrapper.org that points to https://somesite.com/script.php. In this case, $_SERVER['SERVER_NAME'] is somesite.com. How can I access sitewrapper.org?

I need to execute some code based on the URL the user is accessing the site through, not the actual server name.

Look at $_SERVER['HTTP_HOST']. It should contain host name and port, as it was requested by http client.