Back to Top

How to set DirectoryIndex using .htaccess?

Set DirectoryIndex using .htaccess

DirectoryIndex is specifies that which file the Apache server use as index for the directory listing.In simple words, DirectoryIndex is used to set the defalut page on the Apache server.

Default page is the page which is rendered when you type domain name or url in browser where URL redirects to the document root directory which will serve the default file set in the Apache configuration.

You can specify multiple index file names in the DirectoryIndex directive.Here I am going to explain how to set DirectoryIndex using .htaccess file.

Let’s see the SYNTAX of DirectoryIndex directive

DirectoryIndex command will tells the server that to check any of listed file exists,if file is found on server,it should return to the webclient.

Most of the Web servers have index.html as default file but if you are using a shared server, you don’t have access of Apache configuration so you have to configure DirectoryIndex using htaccess file.

You can set DirectoryIndex by writing following line of code into htaccess.

After placing above code in your htaccess file you server will search welcome.htm first,then index.php and then after it will check existence of index.html.

Listing of many files create problems because server have to look for many files existence which could make server slower.

Recommended Read:

To set Expire Headers using .htaccess
Password protection with htaccess

Hope this article helpful to you.As always, thanks for reading an article. Don’t Forget to Follow us on Twitter or Subscribe us to Get the Latest Updates.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Most Popular Posts

Basic Github commands

Posted on 8 years ago

Bhumi

how to shake a div using jQuery

Posted on 11 years ago

Bhumi

New Features in MySQL 5.6

Posted on 12 years ago

Bhumi

How to change Quotes in WordPress

Posted on 11 years ago

Bhumi