1000 FAQs, 500 tutorials and explanatory videos. Here, there are only solutions!
List the contents of a folder that has no index
This guide explains the directive "Options +Indexes
" for Web Hosting, which facilitates navigation for visitors and allows for more advanced customization of how files are displayed.
Introduction
- One of the main advantages of enabling directory indexing is that visitors can view and list all files and subdirectories of a given directory, even if they do not know the exact name of the file they are looking for. This can be particularly useful for file-sharing websites or download sites.
- Directory indexing also makes navigation easier for visitors who are not familiar with the site's file structure. They can simply browse through the subdirectories to find the file or folder they need.
- The directive "
Options +Indexes
" can be customized to display additional information, such as the size and modification date of files, or to hide specific files or directories. - Without this directive, a visitor may encounter an error of the type:
Accès interdit!
Vous n'avez pas le droit d'accéder au répertoire demandé.
Soit il n'y a pas de document index soit le répertoire est protégé.
Si vous pensez qu'il s'agit d'une erreur du serveur, veuillez contacter le gestionnaire du site.
Error 403
List the contents of a Web folder
To list the contents of a folder without a specific index:
- Create a .htaccess file in the relevant folder.
- Enter the following command:
Options +Indexes
Note that this solution will only work if you have no index in the directory in question; you must remove the files index.php
, index.html
, index.htm
, etc. but also the possible file welcome.php
…
Customize the display
Here is an example of code to customize the appearance of the file list generated by Apache:
Options +Indexes
IndexOptions FancyIndexing
IndexOptions FoldersFirst IgnoreCase NameWidth=* DescriptionWidth=* Charset=UTF-8
HeaderName header.html
ReadmeName footer.html
In this example, the user enables the "Indexes
" option, adds the "FancyIndexing
" option for a more aesthetic appearance, specifies the sorting order of the files, defines the column width for the name and description of the files, and specifies the file names to use for the header and footer of the file list.