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. Required fields are marked *

Most Popular Posts

How to Create a Zip File In PHP

Posted on 6 years ago

Bhumi

How to clean HTML content in PHP?

Posted on 3 years ago

Bhumi

To access windows shared files in ubuntu

Posted on 5 years ago

Bhumi

Getting Started with Google Apps Script

Posted on 1 year ago

Bhumi

How to use Ajax in WordPress

Posted on 4 years ago

Bhumi

Overview of ECMAScript 6 new Features

Updated 18 years ago

Bhumi

Getting started with Amazon Web Services

Updated 18 years ago

Bhumi

Facade implementation in Laravel

Updated 18 years ago

Bhumi

The Reader’s Poll – June 2015

Posted on 2 years ago

Bhumi

The Reader’s Poll – August 2014

Posted on 3 years ago

Bhumi

The Reader’s Poll – June 2014

Posted on 3 years ago

Bhumi

The Readers’ Poll – May 2014

Posted on 3 years ago

Bhumi

The Readers’ Poll – August 2013

Posted on 4 years ago

Bhumi