Change default directory page using .htaccess
I know you guzy all know about index file. This is the default file which is executed in the web server. For example, if you type”http://roshanbh.com.np” in this the browser, the “index.php” gets loaded first. This “index.php” file is commonly know as directory index file.
Basically , the default executed file in the web directory starts with “index” such as “index.php”, “index.htm”, “index.html”, “index.aspx” etc.
Last time in one server, I’ve faced a problem. “index.html” as getting executed by default but “index.php” as not getting executed.In such kind of scenario, we may need to change the default file to be executed in the web directory.
Changing Default Directory index page using .htaccess
The default directory index pages are defined in the apache’s configuration file and it can be override from .htaccess file. To do so put the following code in the .htaccess file,
DirectoryIndex index.html index.htm index.php index.cgi
Remember that you can also append the other names of files in the DirectoryIndex directive and the order of the above “DirectoryIndex” directive determines the order of index file in web directory.
First of all, “index.html” file is looked inside directory and if that file is not found then “index.htm” file is looked and if that is also not found then again seek for “index.php” and so on. If any file defined above directive can’t be found in the directory, then web server just list the files inside that directory if the directory listing is enabled. You can also prevent the directory listing using .htaccess file.