index.php not loading by default


I have just installed CentOS, Apache and PHP. When I visit my site, it says "forbidden". By default it's not loading the index.php file.

When I visit, it works fine.

Any idea how to fix that issue?

9/30/2016 9:56:05 AM

Accepted Answer

Apache needs to be configured to recognize index.php as an index file.

The simplest way to accomplish this..

  1. Create a .htaccess file in your web root.

  2. Add the line...

DirectoryIndex index.php

Here is a resource regarding the matter...

Edit: I'm assuming apache is configured to allow .htaccess files. If it isn't, you'll have to modify the setting in apache's configuration file (httpd.conf)

3/5/2010 3:48:58 AM

While adding 'DirectoryIndex index.php' to a .htaccess file may work,


In general, you should never use .htaccess files

This is quoted from
Although this refers to an older version of apache, I believe the principle still applies.

Adding the following to your httpd.conf (if you have access to it) is considered better form, causes less server overhead and has the exact same effect:

<Directory /myapp>
DirectoryIndex index.php

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow