我正在使用Apache Friends XAMPP在 Windows(本地服务器)中。我在 Apache 配置目录中的 httpd-vhosts.conf
中设置了虚拟主机,如下所示
NameVirtualHost *:80
<VirtualHost *:80>
ServerName test.example.com
DocumentRoot "E:\xampp\htdocs\example"
</VirtualHost>
当我浏览 URL 时效果很好
http://test.example.com
是否可以从 Apache .htaccess 动态创建虚拟主机?
最佳答案
VirtualHost
的上下文必须是服务器配置
。请参阅Apache docs .
This means that the directive may be used in the server configuration files (e.g., httpd.conf), but not within any or containers. It is not allowed in .htaccess files at all.
关于apache - 如何从 Apache .htaccess 创建虚拟主机?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6275620/