Home

DirectoryIndex

DirectoryIndex is a configuration directive used by web servers to specify the default file name to serve when a client requests a URL that maps to a directory rather than a specific file. It lists one or more filenames.

In Apache HTTP Server, DirectoryIndex is provided by the mod_dir module and can be set globally in

If a request targets a directory and none of the listed index files is present, the server's

The directive is commonly used to prefer PHP-backed index pages or static HTML. It interacts with other

Security note: Relying on DirectoryIndex to hide files is not a complete security measure; ensure directory

See also: mod_dir, Directory, httpd.conf, index directive in Nginx, Default Document in IIS.

httpd.conf
or
per-directory
in
.htaccess
or
<Directory>
blocks.
Syntax:
DirectoryIndex
index.html
index.php
index.htm.
The
first
existing
file
among
the
listed
names
is
served.
behavior
depends
on
configuration:
it
may
return
a
403
Forbidden,
404
Not
Found,
or
generate
a
directory
listing
if
the
Options
Indexes
setting
is
enabled.
modules
such
as
mod_negotiation
for
content
negotiation
and
with
Web
frameworks
that
create
index.php
as
the
front
controller.
listings
are
disabled
when
not
intended.
In
other
servers,
Nginx
uses
an
index
directive;
IIS
uses
Default
Document.