【问题标题】:Change default page Apache2 Ubuntu更改默认页面 Apache2 Ubuntu
【发布时间】:2013-10-28 08:52:57
【问题描述】:

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

【问题讨论】:

    标签: ubuntu apache2


    【解决方案1】:

    在 Apache2 中,在 sites-available/default 配置文件的 virtualhost 标记内指定 DirectoryIndex 指令对我不起作用。相反,将DirectoryIndex 指令放在apache2.conf 文件的Directory 标记中,如http://httpd.apache.org/docs/2.2/mod/mod_dir.html#directoryindex 中所述,正是我们想要的。

    【讨论】:

      【解决方案2】:

      您可以在虚拟主机上下文中使用 DirectoryIndex 指令。

      来自apache website

      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>
      

      【讨论】:

      • 以上是目录特定范围配置。用于 apache 环境范围配置。使用 url 下面的指令,更改在 dir.conf stackoverflow.com/questions/2384423/…
      • 完美答案。如果您使用的是 Wordpress,只需添加 DirectoryIndex index.php 并重新启动 apache
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-06-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-05-21
      相关资源
      最近更新 更多