更改默认页面Apache2 Ubuntu

更改默认页面Apache2 Ubuntu,ubuntu,apache2,Ubuntu,Apache2,当我访问我的网站时,会显示所有文件的索引,当我选择特定页面时,html无法访问文件中的图像。如何使Apache2自动启动/var/www/home.html而不是/var/www?您可以在虚拟主机上下文中使用DirectoryIndex指令 从 DirectoryIndex指令设置要查找的资源列表, 当客户端通过指定/ 在目录名的末尾 下面是一个例子: <virtualhost *:80> ServerName domain.com ServerAlias www.dom

当我访问我的网站时,会显示所有文件的索引,当我选择特定页面时,html无法访问文件中的图像。如何使Apache2自动启动/var/www/home.html而不是/var/www?

您可以在虚拟主机上下文中使用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>

ServerName域名.com
ServerAlias www.domain.com
#索引文件和文档根目录(公共文件所在的位置)
目录索引home.html index.html
DocumentRoot/var/www

在Apache2中,在
virtualhost
中指定
sites available/default
配置文件中的
DirectoryIndex
指令对我不起作用。相反,在
apache2.conf
文件的
DirectoryIndex
标记中放置
DirectoryIndex
指令正是我们想要的。

以上是特定于目录的范围配置。用于apache环境范围配置。使用url下面的说明,并在dir.conf完美答案中进行更改。如果您使用的是Wordpress,请仅添加DirectoryIndex.php并重新启动apache