使用相同的地址将不同的ServerPath映射到不同的DocumentRoot

我正在使用Intranet中的Apache服务器来访问报告。 我想用相同的服务器名称将服务器path映射到恰好是文件共享的不同文档。

这对VirtualHost是否可行?

<VirtualHost *:80> ServerPath /path1 DocumentRoot remote-share ServerName servername </VirtualHost> <VirtualHost *:80> ServerPath /path2 DocumentRoot remote-share ServerName servername </VirtualHost> <Directory /path1> Options Indexes </Directory> <Directory /path2> Options Indexes </Directory> 

在这种情况下,path1工作,但是覆盖了path2,因此path2从不工作 – 可能是因为它是同一个虚拟主机 – 但是我需要拥有相同的地址,不同的子文件夹映射到不同的DocumentRoot。

你可以尝试使用mod_aliasAlias指令

 <VirtualHost *:80> ServerName servername DocumentRoot /dummy/path Alias /path1 /path/to/mounted/fs/path1 Alias /path2 /path/to/other/fs/path2 </VirtualHost> 

有关详细信息,请参阅http://httpd.apache.org/docs/2.2/mod/mod_alias.html#alias