Home > Backend Development > PHP Tutorial > php如何靠谱的获取当前域名?

php如何靠谱的获取当前域名?

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-06 20:35:59
Original
942 people have browsed it

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

回复内容:

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

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

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

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

Related labels:
php
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template