How to change which page loads first
How a folder decides which file to show first, and how to change that order if you need to.
When you visit a folder on a website without naming a specific file, the server looks for a default page to show, checking a fixed list of filenames in order and loading the first match it finds. If the file you expect to load is not the one that actually appears, this order — not something broken — is almost always why.
The typical default order
A common default index list looks something like this, checked top to bottom:
index.html
index.htm
index.php
So if a folder contains both index.html and index.php, the server loads index.html and never even looks at the PHP file — regardless of which one is newer, or which one you actually meant to be live. This is a genuinely common source of confusion after uploading a new site: an old placeholder index.html left over from a previous setup can quietly keep showing itself while a freshly installed index.php sits right next to it, unused.
Some hosting configurations check the list in a slightly different order, or include additional filenames. If you are not sure what your account checks first, the fastest way to find out is simply to test it — the behaviour described below works regardless of the exact order.
Fixing it
- Delete or rename the file you do not want loaded. If an old
index.htmlis blocking a realindex.php, removing or renaming that leftover file is usually the simplest fix — check first that nothing else on the site actually depends on it. - Change the priority order. Some control panels expose a setting for which file type takes precedence in a given folder. If yours does, this lets you flip the order without touching any files.
- Set it explicitly in .htaccess. A line such as
DirectoryIndex index.php index.htmltells the server exactly which file to prefer in that folder, overriding the server-wide default for that location only. See how to use .htaccess if you want to go this route.
Why a folder shows a file listing instead of any page
If a folder contains none of the filenames the server checks for, and directory browsing happens to be switched on, the server may show a plain list of the folder's files instead of any page at all. This is a related but separate issue from the wrong file loading — see turning directory listings on or off if that is what you are actually seeing.
In either case, the underlying folder your domain points at is usually the same one referred to elsewhere as the web root, commonly named public_html — see what is the public_html folder if that term is unfamiliar.
Frequently asked questions
Why does my site load index.html instead of index.php?
The web server checks for files matching a default list, in a fixed order, and loads the first one it finds. index.html is usually checked before index.php, so if both exist in the same folder, the HTML file wins even if the PHP file is the one you actually want shown.
How do I change the order?
Either delete or rename the file you do not want loaded, or set a custom priority order through your control panel or a DirectoryIndex line in .htaccess, if your setup supports editing it directly.
Related reading
One file that controls redirects, rewrites and access rules for a whole folder — and one typo in it that can take the site offline.
How to turn directory listings on or offWhat causes a folder to show a bare file listing, and how to turn that behaviour on or off deliberately.
What is the public_html folder?It is the one folder on your hosting account that visitors can actually reach. Everything your site shows has to live inside it.
A tour of your hosting control panelThe main sections you will find in your control panel and roughly what lives in each one.