使用 Apache 将 URL 路径视为虚拟主机 [英] Treat URL path as virtual host using Apache
问题描述
问题是我只有一个域名,需要运行三种不同的产品(其中两种基于 PHP,一种基于 Python).所以我需要把URL中的路径当作不同的虚拟主机;即:
The problem is that I have only one domain name on which three different products need to be run (two of them PHP based and one python). So I need to treat the path in the URL as a different virtual host; i.e.:
www.domain.com/first_URL/
www.domain.com/second_URL/
www.domain.com/third_URL/
第一个到第三个将充当单独的虚拟主机.
Where the first to third will act as separate virtual hosts.
我该怎么做?
推荐答案
您可能想要使用 apache-config 指令做一些事情,因为您需要一个虚拟主机解决方案.Apache 只能使用 virtualHosts 作为实际域,如 cweiske解释.
You probably want to do something with the apache-config directives, since you're asking for a virtualhost solution. Apache can only work with virtualHosts as actual domains, as cweiske explained.
在这种情况下的解决方案是在您正在工作的子目录中使用 .htaccess
文件,或者设置一个
The solution in this case would be to either use a .htaccess
file in the sub-directories you're working in, or to set up a <Directory "/web/root/subdir">..</Directory>
block within your current (virtual-)host configuration.
如果您本身想将它们作为 VirtualHosts ('app1.domain.org') 运行,您也可以选择将它们托管在不同的子域上.
You could also choose to host them on different sub-domains if you per se want to run them as VirtualHosts ('app1.domain.org').
这篇关于使用 Apache 将 URL 路径视为虚拟主机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!