00 Votes

Multiple index files: force server to load index.php instead of index.html

Question by Guest | 2012-08-24 at 21:35

I have the following unusual problem: In my webspace directory is both an index.php and an index.html. For some reason, however, always the index.html is loaded first. But I would like, that the index.php is loaded first instead.

Is there a way or is not changeable?

00 Votes

Why do you have an index.html and an index.php in the directory? That does not really make much sense, does it? I would leave only one index file in the directory and call the rest of the files differently, possibly with links. Then you have not the problem.
2012-08-27 at 20:46

ReplyPositive Negative
00 Votes

You can customize your htaccess file to set the access order to the files. Add the following line in the htaccess:

DirectoryIndex index.php index.html

With this, it will be looked for your index.php first, and then, after that, for index.html. If both are not present, there will be an Access Forbidden Error (403) or the directory with all the files will be displayed.

Behind DirectoryIndex, you can also specify files not named index. For example:

DirectoryIndex abc.html def.php index.php

Then, first the abc.html is displayed, if available. And after that, def.php or index.php - depending on which of the files are available.
2012-08-26 at 16:42

ReplyPositive Negative

Related Topics

Important Note

Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.


Ask your own question or write your own article on askingbox.com. That’s how it’s done.