On HostGinger Hosting servers, by default, when users access a URL that requests a directory, such as http://xyz.com/products, the web server searches for a file called index.html in the products directory. If there is no index.html file, the web server looks for index.htm and other files with similar names. The web server either lists the files in the current directory (if directory index listings are enabled) or displays a "403 Forbidden" error message (if directory index listings are disabled) if none of these files can be found.

To define a specific file or files that the web server looks for when a visitor requests a directory, use the DirectoryIndex directive in an .htaccess file. Make the following changes to the .htaccess file using a text editor to enable the DirectoryIndex directive.

Replace filename with the file that you want to display whenever a user requests the directory:

DirectoryIndex filename

Additionally, you can specify more than one filename, in which case the web server will check each one until it finds a match. Take the following directive as an example:

DirectoryIndex index.php index.html index.htm

With this directive, the web server first searches for an index.php file when a visitor requests the directory name. It searches for an index.php file first, then an index.html file, and so on until it finds a match or runs out of files to search.

Was this answer helpful? 0 Users Found This Useful (0 Votes) htaccess file, htaccess rule, htaccess file protection