8

When I go to my website an index of all the files shows up, when I choose a specific page the html isn't able to access the images in a file. How can I make Apache2 automatically launch /var/www/home.html instead of /var/www?

Wesxdz
  • 97
  • 1
  • 2
  • 5

2 Answers2

11

You can use DirectoryIndex directive in vitual host context.

From apache website

The DirectoryIndex directive sets the list of resources to look for, when the client requests an index of the directory by specifying a / at the end of the directory name.

Here's the example:

<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>
Chawarong Songserm PMP
  • 1,734
  • 1
  • 14
  • 19
  • above is directory specific scope configuration. for apache environment scope configuration. use instruction below url and the changes are made in dir.conf https://stackoverflow.com/questions/2384423/index-php-not-loading-by-default – Dung Apr 12 '18 at 16:00
  • Perfect Answer. If you are using Wordpress only add DirectoryIndex index.php and restart apache – Piyush Patil Jul 22 '19 at 22:43
3

In Apache2, specifying DirectoryIndex directive inside virtualhost tag of sites-available/default configuration file didn't work for me. Instead, placing DirectoryIndex directive inside Directory tag of apache2.conf file as mentioned in http://httpd.apache.org/docs/2.2/mod/mod_dir.html#directoryindex did exactly what we want.

gulam
  • 124
  • 1
  • 1
  • 8