How do I make Apache automatically load "index.php" files, the same way it loads "index.html" files?

| |

You will need to be root to do all of the following.

  1. Go to the directory where the apache configuration files reside, typically in "/www/conf/".
  2. The file you will need to edit will probably be "httpd.conf". To be sure you are editing the correct file, grep the configuration files for "index.html", since you will want "index.php" to have the same behavior:

    niflheim: grep index.html *.conf
    httpd.conf: DirectoryIndex index.html

  3. Edit the appropriate file (httpd.conf) and search for "index.html".
  4. You should see the following line:

    <IfModule mod_dir.c>
    DirectoryIndex index.html

    Add "index.php" so that it occurs one space after "index.html".

  5. Your file should ultimately look like this:

    <IfModule mod_dir.c>
    DirectoryIndex index.html index.php

  6. Save the file and restart Apache with the following sequence of commands:

    niflheim: cd ../bin/
    niflheim: ./apachectl restart

  7. Your "index.php" files should now load by default.

Still have a question?

Didn't find what you were looking for? Do you still have a question you need an answer to? Just click here to send us a message, and a memeber of our staff will contact you shortly.