如何在Apache中将DirectoryIndex设置为<foldername> .html?

我正在运行Apache,而且我已经厌倦了编辑所有名为index.html的数百个文件。 我想要的是这样的:

/root/foo DirectoryIndex: foo.html /root/bar DirectoryIndex: bar.html /root/bar/narf DirectoryIndex: narf.html 

…但自动,为我所有的目录。 有没有办法在Apache中做到这一点?

从你的评论,你没有坚持DirectoryIndex的想法,我敢打赌,你可以用mod_rewrite完成同样的壮举。 就像是

 RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^/(.*)/(.*)$ http://mysite.com/$1/$2/$2.html [L] 

上面没有经过testing,只是一个普遍的想法,你想获得整个path,并提供最后一个文件夹名称.html文件,如果请求的文件名不存在。 正如我所说的没有testing出确切的语法获取目录path。