Specify landing page with Apache webserver

The Apache Webserver is normally clever enough to tell which PHP/HTML/… file to use as the landing page of an URL. For instance, if you type http://blog.roland-kluge.de in your URL bar, the Webserver knows that you actually want to see http://blog.roland-kluge.de/index.php. Default files to redirect to are index.html, index.php and some more. However, sometimes the webserver may be hindered from finding the correct redirect and produces an appropriate HTML error code.

You may tell Apache which file to redirect to with the following directive in the web site’s root .htaccess:

DirectoryIndex index.html

You may even specify multiple sites which will be probed in the given sequence:

DirectoryIndex index.html somethingWentWrong.html

Links

  • [1] mod_dir reference providing the DirectoryIndex directive

Leave a Reply