问题描述
问题是我只有一个域名,需要在该域名上运行三种不同的产品(其中两种基于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
文件,或设置< Directory"/web/root/subdir"> ..</Directory>
块放在当前(虚拟)主机配置中.
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路径视为虚拟主机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!