Organizational Research By

Surprising Reserch Topic

Is your Web Server Serving the Correct Index Files?

If your document root is correct and your index pages are not being served correctly when you go to your site or a directory location on your site, you may have your indexes configured incorrectly.

When a visitor requests a directory, typically your server will want to give them an index file. This is usually an index.html file or an index.php file depending on your configuration.

In Apache, you may find a line in your virtual host file that configures the index order that will be used for specific directories explicitly, like this:

    DirectoryIndex index.html index.php

This means that when the directory is being served, Apache will look for a file called index.html first, and try to serve index.php as a backup if the first file is not found.

You can set the order that will be used to serve index files for the entire server by editing the mods-enabled/dir.conf file, which will set the defaults for the server. If your server is not serving an index file, make sure you have an index file in your directory that matches one of the options in your file.

In Nginx, the directive that does this is is called index and it is used like this:

server {
    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;
    root /usr/share/nginx/html;
    index index.html index.htm;
. . .
asked Aug 29, 2015 in LINUX by rajesh
0 votes

Related Hot Questions

Government Jobs Opening