Apache / PHP:无论如何通过PHP检索ServerName设置
我有一个Apache虚拟主机,如下所示:
<VirtualHost *:80>
ServerName host1.example.com
ServerAlias host2.example.com
DocumentRoot /srv/web/host1.example.com/pub
</VirtualHost>
我有以下文件:
/srv/web/host1.example.com/pub/test.php
我要求提供以下网址(注意我使用的是ServerAlias
,而不是ServerName
:
http://host2.example.com/test.php
我想test.php
以某种方式输出ServerName
变量(host1.example.com
)。有没有办法做到这一点?
没有找到相关结果
已邀请:
1 个回复
杰黔轿缺
在任何
变量中。 想到的唯一想法是设置一个环境变量:
这应该将
的值设置为正确的主机名。虽然没有保证,但我从未尝试过这种做法。