[英]Get the hostname in the url using PHP on AWS Elastic Beanstalk
Inside a PHP application hosted on Elastic Benstalk I'd like to get and use the host, or domain, part of the url the client used to load the page. 在Elastic Benstalk上托管的PHP应用程序内部,我想获取和使用主机或域,即客户端用于加载页面的部分URL。
In the past, but on non AWS servers, I have used: 过去,但在非AWS服务器上,我使用了:
$hostname = $_SERVER[HTTP_HOST];
which would return example.com
from a url like http://example.com/index.html
. 它将从类似
http://example.com/index.html
的网址返回example.com
。 What I'm getting from my code deployed on elastic beanstalk appears to be the ip address of the running instance; 我从部署在弹性beantalk上的代码得到的似乎是正在运行的实例的ip地址。 it's something like
53.123.123.123
. 就像
53.123.123.123
一样。
Is there a way to get the host name - or domain name - of the url that the client web browser requested from my Elastic Beanstalk PHP Application? 有没有办法获取客户端Web浏览器从我的Elastic Beanstalk PHP应用程序请求的URL的主机名或域名?
You should look in 你应该看看
$_SERVER['SERVER_NAME']
Instead 代替
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.