如何根据里面的文件设置VirtualDocumentRoot

我试图设置Apache使用VirtualDocumentRoot指令,但我的网站并不完全相同。 大多数网站都有一个drupal文件夹,它应该是根,但是有一些真正的老的drupal网站,一些rails站点,一些django站点等等,它们希望Document根为/或者其他文件夹。

有没有一种方法来设置基于条件的VirtualDocumentRoot或有没有办法使用RewriteRule / Cond检测/如果有一个drupal文件夹或公用文件夹是不正确的文件夹?

以下是我到目前为止:

<VirtualHost *:80> # Wildcard ServerAlias, this is the default vhost if no specific vhost matches first. ServerAlias *.unicorn.devserver.com # Automatic ServerName, based on the HTTP_HOST header. UseCanonicalName Off # Automatic DocumentRoot. This uses the 4th level domain name as the document root, # for example http://bar.foo.baz.com/ would respond with /Users/vosechu/Sites/bar/drupal. VirtualDocumentRoot /Users/vosechu/Sites/%-4/drupal </VirtualHost> 

提前致谢!

查克

Is there a way to set up VirtualDocumentRoot based on a conditional

没有 – 这根本就不是VirtualDocumentRoot工作方式 – 它分开一部分主机名并将其粘贴到path中。


or is there a way to use RewriteRule/Cond to detect that '/' is the incorrect folder if there is a drupal folder or a public folder?

我不是100%确定你在这里问什么,但它听起来像“有没有一种方法,使Apache的行为不同的目录内容的基础上? – 如果是这样,答案几乎是“否”:
Apache只是服务于它的东西。 它知道如果一个目录是一个Drupal站点“知道”的方法(它只是看到一个PHP文件,并启动一个PHP解释器,因为这是PHP文件所做的事情,并吐出解释器给出的结果背部)。


你似乎试图推动你的根本不同的网站的方形钉到VirtualDocumentRoot圆孔(这真的是最适合死的简单的网站) – 在你的情况,我认为你真的需要为每个网站创build单独的虚拟主机并分别pipe理他们的configuration。