Webserver directory index
Webserver Directory Index
A webserver directory index is a file served to visitors by a web server when no specific file is requested within a directory. Commonly named files for this purpose include index.html, index.htm, index.php, and default.htm, among others. The webserver is configured to look for these files in a specified order when a directory URL is requested. If none of these files are found, the server may return a 404 Not Found error, or it may display a generated list of files in the directory, depending on its configuration.
Overview[edit | edit source]
When a user requests a URL that corresponds to a directory on the web server rather than a specific file, the web server must decide what content to serve. This is where the directory index file plays a crucial role. It acts as the default or "home" page for that directory, providing an entry point for users. The selection of the directory index file is governed by the server's configuration, typically defined in the server's main configuration file or in a .htaccess file in the directory itself.
Configuration[edit | edit source]
The configuration of directory indexes varies between web servers.
Apache[edit | edit source]
In Apache, the DirectoryIndex directive is used to specify a list of files to look for as the directory index. For example: ``` DirectoryIndex index.html index.php default.php ``` This configuration tells Apache to look for index.html first, then index.php, and finally default.php when serving a directory.
Nginx[edit | edit source]
In Nginx, the index directive serves a similar purpose. It is placed within a server or location block: ``` index index.html index.htm index.php; ```
Security Considerations[edit | edit source]
Serving a directory listing can inadvertently expose sensitive files or information to the public. Therefore, it is a common security practice to disable directory listings unless they are explicitly required. This can be achieved by ensuring a valid directory index file is present or by configuring the server to not list directory contents.
See Also[edit | edit source]
References[edit | edit source]
Search WikiMD
Ad.Tired of being Overweight? Try W8MD's physician weight loss program.
Semaglutide (Ozempic / Wegovy and Tirzepatide (Mounjaro / Zepbound) available.
Advertise on WikiMD
WikiMD's Wellness Encyclopedia |
Let Food Be Thy Medicine Medicine Thy Food - Hippocrates |
Translate this page: - East Asian
中文,
日本,
한국어,
South Asian
हिन्दी,
தமிழ்,
తెలుగు,
Urdu,
ಕನ್ನಡ,
Southeast Asian
Indonesian,
Vietnamese,
Thai,
မြန်မာဘာသာ,
বাংলা
European
español,
Deutsch,
français,
Greek,
português do Brasil,
polski,
română,
русский,
Nederlands,
norsk,
svenska,
suomi,
Italian
Middle Eastern & African
عربى,
Turkish,
Persian,
Hebrew,
Afrikaans,
isiZulu,
Kiswahili,
Other
Bulgarian,
Hungarian,
Czech,
Swedish,
മലയാളം,
मराठी,
ਪੰਜਾਬੀ,
ગુજરાતી,
Portuguese,
Ukrainian
WikiMD is not a substitute for professional medical advice. See full disclaimer.
Credits:Most images are courtesy of Wikimedia commons, and templates Wikipedia, licensed under CC BY SA or similar.
Contributors: Prab R. Tumpati, MD