在虚拟主机之外添加apache2 DirectoryIndex

我有我的服务器上的几个虚拟主机网站,并希望使Apache加载设置文件,如果没有索引文件存在。 我试过了

DirectoryIndex /index.php 

但是只加载虚拟主机根目录下的索引。 接下来我尝试了

 DirectoryIndex /var/www/index.php 

但是这个错误404又回来了,于是我试了一下

 DirectoryIndex /../index.php 

但是也返回了错误400。 Google的所有结果都是关于如何禁用默认索引,而不是取代它。

我的文件树是

 www > index.php (file I wish to load if no index) virtualhostsite1 > pages subdirectories etc. virtualhostsite2 > pages subdirectories etc. virtualhostsite3 > pages subdirectories etc. 

简而言之,我想用一个存储在硬盘驱动器其他地方的Apache根之外的自定义索引replace这个屏幕 。 我希望这是有道理的。

根据Apache HTTPd文档 ,您只需使用

 DirectoryIndex index.php 

这将使用文件index.php作为每个目录内的目录索引。

你也可以给一个文件列表来尝试。 所以如果不存在index.html ,应该使用index.php (如果存在)。

 DirectoryIndex index.html index.php 

该文件说:

Local-url是服务器上相对于请求目录的文档的(%编码)URL; 它通常是目录中文件的名称。

所以我想你是非常接近的。 尝试:

 DirectoryIndex ../index.php