【发布时间】:2013-10-28 08:52:57
【问题描述】:
当我访问我的网站时,会显示所有文件的索引,当我选择特定页面时,html 无法访问文件中的图像。如何让 Apache2 自动启动 /var/www/home.html 而不是 /var/www?
【问题讨论】:
当我访问我的网站时,会显示所有文件的索引,当我选择特定页面时,html 无法访问文件中的图像。如何让 Apache2 自动启动 /var/www/home.html 而不是 /var/www?
【问题讨论】:
在 Apache2 中,在 sites-available/default 配置文件的 virtualhost 标记内指定 DirectoryIndex 指令对我不起作用。相反,将DirectoryIndex 指令放在apache2.conf 文件的Directory 标记中,如http://httpd.apache.org/docs/2.2/mod/mod_dir.html#directoryindex 中所述,正是我们想要的。
【讨论】:
您可以在虚拟主机上下文中使用 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>
【讨论】: