apache - 如何从 Apache .htaccess 创建虚拟主机?

标签 apache .htaccess mod-rewrite url-rewriting virtualhost

我正在使用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.

( Directive Dictionary )

关于apache - 如何从 Apache .htaccess 创建虚拟主机?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6275620/

相关文章:

wordpress - 我应该在 WordPress 中使用选项 - 索引吗?

regex - GET-请求中的具体参数 : don't doing 301 redirect

apache - 设置自定义处理程序时重定向失败

.htaccess - htaccess 重写破坏了相对路径

apache - centos 7上Nginx反向代理apache,同时配置http和https

java - 虚拟主机 Apache 和 Tomcat

.htaccess - 将所有子域重定向到一页

PHP没有在子域上保存 session ,在域上可以

apache - 单个文件夹的 SSL 异常(exception)

apache - htaccess 将 RewriteBase 设置为请求 URI 的开头