如何从Apache .htaccess创建虚拟主机? [英] How to create Virtual Host from Apache .htaccess?
问题描述
我正在Windows(本地服务器)中使用 Apache Friends XAMPP .我在这样的Apache配置目录中的httpd-vhosts.conf
中设置虚拟主机
I am using Apache Friends XAMPP in Windows (Local Server). I setup the virtual host in httpd-vhosts.conf
in an Apache configuration directory like this
NameVirtualHost *:80
<VirtualHost *:80>
ServerName test.example.com
DocumentRoot "E:\xampp\htdocs\example"
</VirtualHost>
当我浏览URL时,此方法正常工作
This works fine when I browse the URL
http://test.example.com
是否可以从Apache .htaccess动态创建虚拟主机?
Is it possible to create virtual host from Apache .htaccess dynamically?
推荐答案
VirtualHost
的上下文必须为server config
.请参见 Apache文档.
The context for VirtualHost
has to be server config
. See the Apache docs.
这意味着该指令可能是 在服务器配置文件中使用 (例如,httpd.conf),但不在任何范围内 或者 容器.不允许进入 根本没有.htaccess文件.
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 .htaccess创建虚拟主机?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!