User Name
Password
AppleNova Forums » Programmer's Nook »

PHP: making index files work


Register Members List Calendar Search FAQ Posting Guidelines
PHP: making index files work
Thread Tools
drewprops
Space Pirate
 
Join Date: May 2004
Location: Atlanta
 
2005-11-20, 02:26

I've set up a new website using PHP but to my surprise the index page (index.php) doesn't automatically load in Safari or Firefox. Can anyone enlighten me as to what I'm supposed to do to make a PHP index page load automatically like HTML index pages normally do? Am I supposed to alter the .htaccess file? Keep banging the rocks together?

Steve Jobs ate my cat's watermelon.
Captain Drew on Twitter
  quote
chucker
 
Join Date: May 2004
Location: near Bremen, Germany
Send a message via ICQ to chucker Send a message via AIM to chucker Send a message via MSN to chucker Send a message via Yahoo to chucker Send a message via Skype™ to chucker 
2005-11-20, 02:32

Quote:
Originally Posted by drewprops
I've set up a new website using PHP but to my surprise the index page (index.php) doesn't automatically load in Safari or Firefox. Can anyone enlighten me as to what I'm supposed to do to make a PHP index page load automatically like HTML index pages normally do? Am I supposed to alter the .htaccess file? Keep banging the rocks together?
What webserver are you on? Your local one? A hosted one (in that case, does it offer PHP?).

Presumably, you're on something Apache-based. To make Apache look for index.php files, make sure the DirectoryIndex directive includes that. You can enforce this with .htaccess like this:

DirectoryIndex index.php

You should give more information first what kind of server you're talking about though.
  quote
drewprops
Space Pirate
 
Join Date: May 2004
Location: Atlanta
 
2005-11-20, 02:39

Bingo, Chucker.

It's Apache-based and it's working now. That bit you mentioned...

Code:
DirectoryIndex index.php
.... did the trick.

I just found an article with your same tip in it (in the WordPress docs) and came back here to post that I'd found it. Good show sir, this here programmers forum is pretty spiffy.

Now to bang out the CSS browser bugs in the website.... if anyone is interested the site is www.film-ga.com and is still in giddy first-legs mode~

Steve Jobs ate my cat's watermelon.
Captain Drew on Twitter
  quote
chucker
 
Join Date: May 2004
Location: near Bremen, Germany
Send a message via ICQ to chucker Send a message via AIM to chucker Send a message via MSN to chucker Send a message via Yahoo to chucker Send a message via Skype™ to chucker 
2005-11-20, 02:42

Glad to be of help.
  quote
torifile
Less than Stellar Member
 
Join Date: May 2004
Location: Durham, NC
Send a message via AIM to torifile  
2005-11-21, 00:15

Make sure you don't remove the reference in that line to "index.html". Just put it after the index.php reference. This way, if you don't have an index.php file in the directory, but an index.html, it will automatically load that. I usually add index.htm just for good measure.

edit: I just realized that you're probably not making changes to the httpd.conf file, so never mind. If you are reading this and making changes to the httpd.conf file on your local box, the above applies.

If it's not red and showing substantial musculature, you're wearing it wrong.
  quote
drewprops
Space Pirate
 
Join Date: May 2004
Location: Atlanta
 
2005-11-21, 09:07

Nope, not messing with the httpd.conf file (whatever that is!!).
For confirmation, I did not create a reference to index.html or index.htm in the .htaccess file and am curious if I need to do so (even after reading your edit Tori). I don't have access to that domain while I'm at work so I can't do a quick experiment to see what would happen if I only had an .html or .htm file in there.

What's the normal setup for how these things behave?

Steve Jobs ate my cat's watermelon.
Captain Drew on Twitter
  quote
Majost
monkey with a tiny cymbal
 
Join Date: Nov 2004
Location: Lost
 
2005-11-21, 10:33

I believe .htaccess will override all previous settings. So, you'll want it to say
Code:
DirectoryIndex index.html index.htm index.php
or whatever in the order that you want it.

Just a note to everyone else - .htaccess is disabled by default on Mac OS X. So, if you're locally serving your webpages, you'll want to make these changes inside /etc/httpd/httpd.conf.

And if you want to enable .htaccess, you'll need to change your httpd.conf file such that the second "AllowOverride None" directive becomes "AllowOverride All." And, you'll need to make the same change in /etc/httpd/users/your_username.conf. And then if you're using Virtual Servers, you'll need to add "AllowOverride All" into your virtual server block in httpd.conf.

But, you don't want to enable .htaccess if you don't have to... you end up with a performance hit since Apache looks through every single directory on its way to the file requested for an .htaccess file.

Yeah, I just spent three hours figuring all that out. Figured I'd leave it all here for posterity.
  quote
ast3r3x
25 chars of wasted space.
 
Join Date: May 2004
Send a message via AIM to ast3r3x  
2005-11-21, 12:15

Although the speed his is rather negligable. Maybe more if you are using are hosting locally though.
  quote
Posting Rules Navigation
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Post Reply

Forum Jump
Thread Tools
Similar Threads
Thread Thread Starter Forum Replies Last Post
Empty files copied from networked drive skid_boy_99 Genius Bar 0 2005-10-04 04:23
Automator Renaming Files In Random Order YouCanHaveYourPC Apple Products 4 2005-08-29 19:02
PHP : Passing declared variables to REQUIRE'd files. drewprops Genius Bar 9 2005-01-11 00:03


« Previous Thread | Next Thread »

All times are GMT -5. The time now is 00:32.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004 - 2024, AppleNova