How do I display or change a default page other than index.html or index.php under Apache web server?
You need to use DirectoryIndex directive under Apache to set a default page other than index.html or index.php.
The DirectoryIndex directive sets the list of resources or file to look for, when the client requests an index of the directory by specifying a / at the end of a directory name.
Edit httpd.conf
Open your Apache configuration file httpd.conf
# vi httpd.conf
Find out line that read as follows:
DirectoryIndex
Now set it as per your requirements:
DirectoryIndex index.html index.htm default.htm index.php index.pl
Save and close the file. Restart the Apache web server:
# /etc/init.d/httpd restart
Please note that if you do not have access to Apache configuration file. Add DirectoryIndex to your .htaccess file.
You can also specify php or pl dynamic script. Also note that the documents do not need to be relative to the directory. Consider following example
DirectoryIndex index.html index.pl /nav/index.php
Above would cause the php script /nav/index.php to be executed if neither index.html or index.pl existed in a directory.
- 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
- Top 30 Nmap Command Examples For Sys/Network Admins
- 25 PHP Security Best Practices For Sys Admins
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- Linux: 20 Iptables Examples For New SysAdmins
- Top 20 OpenSSH Server Best Security Practices
- Top 20 Nginx WebServer Best Security Practices
- 20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors
- 15 Greatest Open Source Terminal Applications Of 2012

- My 10 UNIX Command Line Mistakes
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- The Novice Guide To Buying A Linux Laptop







![Apache: [warn] _default_ VirtualHost overlap on port 80, the first has precedence Error and Solution](http://s0.cyberciti.org/images/rp/1/28.jpg)




{ 14 comments… read them below or add one }
THANK YOU SO MUCH :)
I was unable to have Drupal working until I did this. Great :D
Thank u very much… I had same problem with drupal but solved now , and I can view all pages of Drupal.
Thank you very much.
thanks for the guide
Hi, although apache manuals contain this information, your website gives solutions for commonly sought after problems/questions. Useful indeed! Thank you.
What do you to if you wanted to change your default desktop?
A.Use the switchdesk program.
B.Edit /etc/X11/prefdm.
C.Open the .Xdefaults file in your home directory.
D.Link startx to gnome-session or startkde.
Just a note, you don’t have to restart the server to make these changes you can use the reload command
/etc/init.d/apache2 reload
Thank you very much.
I had problem of setting my home page too.
yeah i have done that .. but now my apache list the script that in my index.php is :|…
Thanks,
nice little article…works nicely
how I can make all my php pages extenions(.php) should be shown as html extension(.html). Is there any way I can change that to .php files to .html when client acces the php pages? Please resolve the issue as soon as possible. Thanks!
Thanks Alot:)
I really appreciate!
Thanks for the information. It really helps a lot.
Wooooohhooooo…!!! It worked.. :)
Thanks