dongzhong2018
dongzhong2018
2015-11-19 16:53

使用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条回答

  • doucaishou0074 doucaishou0074 6年前

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

    点赞 评论 复制链接分享

为你推荐