Looking to Build/Redesign a Website or Blog ?

To speak to Rakshit, call +91 968 704 2303

[htaccess] How to change your default Index page

Change Default Index Html php htaccess

Hello Friends,

As a web developer, you will be well aware that default page under directory will be index.html. It is default assumption by any designer, developer or any web expert. But you might not aware that hosting provider sets default.html as default index page so whenever you open any url and if it has directory path, it will try to call default.html. If default.html will not be available than it will list all files under that directory and will not call index.html or index.php.

If you face such problem, you can overrite hosting default index page to whatever you want to set. If you want to set index.html as your default page than you can do it using htaccess.

Set index.html as default index page using htaccess

Create .htaccess file and put it under root directory. Copy below code and paste it in the file.

DirectoryIndex index.html

Now it will call index.html as default index page. If index.html is not available under any directory, it will simple list all directory files. It might be case that you don’t have index.html under all directory and you might need to call index.php file for some. To do so, you can set index.html as first priority and if index.html is not available than it will call index.php file. Here is a code for that.

Set index.php as second default index page using htaccess

DirectoryIndex index.html index.php

You can set as many files as you want. It will start looking in sequence and if none of the file exist, it will list all files under that directory.

Looking for how to set default index page ? index.html file is not calling, index.php file is not calling, index page does not works. All questions like these have one solution. I hope it helps you and saves your little time. Please share with your friends and let them know about the same.

Share:

No Comments Yet.

Leave a Reply

Your email address will not be published.