php如何靠谱的获取当前域名?
ringa_lee
ringa_lee 2017-04-10 15:30:45
0
1
699

$_SERVER['HTTP_HOST'] 经常将域名转换为IP,我也是URL访问的,求解决

ringa_lee
ringa_lee

ringa_lee

reply all(1)
小葫芦

可参考Symfony的HttpFoundation组件里Request类上获取host的方法:

https://github.com/symfony/symfony/blob/2.7/src/Symfony/Component/Http...

需要判断是不是反向代理的请求(从请求头里查),否则从HOST头或$_SERVER变量里取。

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template