当我访问我的网站时,会显示所有文件的索引,当我选择特定页面时,html无法访问文件中的图像。 如何使 Apache2 自动启动/var/www/home.html 而不是/var/www?
您可以在 vitual 主机上下文中使用 DirectoryIndex 指令。
来自阿帕奇网站
DirectoryIndex 指令设置要查找的资源列表, 当客户端通过指定/请求目录的索引时 在目录名称的末尾。
下面是示例:
<virtualhost *:80>
ServerName domain.com
ServerAlias www.domain.com
# Index file and Document Root (where the public files are located)
DirectoryIndex home.html index.html
DocumentRoot /var/www
</virtualhost>
在 Apache2 中,在配置文件virtualhost
标签中指定DirectoryIndex
指令sites-available/default
对我不起作用。相反,如 http://httpd.apache.org/docs/2.2/mod/mod_dir.html#directoryindex 中所述DirectoryIndex
将指令放在apache2.conf
文件的Directory
标签中,这正是我们想要的。