[SOLVED] Setting index.php as website homepage

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
squire
Forum Newbie
Posts: 4
Joined: Wed Jan 26, 2005 7:22 pm
Location: Belfast, Ireland

[SOLVED] Setting index.php as website homepage

Post by squire »

hi,

I have been using PHP now for a few months or so all on my localhost webserver (Apache). I am running PHP version 4.3.9 as well as MySQL.

My problem is that I want to set index.php as my homepage on my website but testing it on my localhost it does not seem to work. How can I set my homepage to index.php rather than index.html or whatever. I know I can do this for ASP but I am unsure regarding PHP.

Any help is greatly appreciated.

Thanks for reading.
rehfeld
Forum Regular
Posts: 741
Joined: Mon Oct 18, 2004 8:14 pm

Post by rehfeld »

you could put this in a .htaccess file

Code: Select all

DirectoryIndex index.php index.html foo.htm
apache will read from left to right,
if for example, there is not a file named index.php, then it would look for index.html, and if it cant find index.html, then it would try foo.htm etc......

thats assuming your using apache. i dont know how to do it on other webservers
squire
Forum Newbie
Posts: 4
Joined: Wed Jan 26, 2005 7:22 pm
Location: Belfast, Ireland

Post by squire »

rehfeld you were spot on. After a bit of Googling regarding the DirectoryIndex I found that I should go to and open:

C:\Program Files\Apache Group\Apache\conf\httpd.conf

once inside the httpd.conf I searched for DirectoryIndex and relpaced:

DirectoryIndex index.html

TO

DirectoryIndex index.php index.html

This worked perfectly. Thank you again. I hope I can help others by stating what I have done. :)
Post Reply