Look at $_SERVER['HTTP_HOST']
. It should contain host name and port, as it was requested by http client.
使用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.
- 点赞
- 写回答
- 关注问题
- 收藏
- 复制链接分享
- 邀请回答
1条回答
为你推荐
- 使用DNS支持在PHP中获取当前URL
- drupal
- dns
- php
- 1个回答