Not recognizing index files locally

He has: 698 posts

Joined: Jul 2005

I have recently installed Apache 2.0, PHP 5.0, and MySQL 5.0 on my Windows system to design websites and test PHP scripts locally instead of uploading (pretty much the reason why anybody does so...waste of space, this message is). Anywho, when I type a directory in the address bar, one under the base http://localhost/, instead of displaying the index file of that directory, it displays the contents of that directory as if there is no index file. (I've tried index.php, index.htm, and index.html, and none work) It would be handy if it displayed it like it did when you browse something on the web. Is there a setting somewhere in my php.ini file or anything I can change/add to get this to work? It would be a huge asset. Not completely necessary, but a big help.

One more thing I'm having trouble with, even after reading the documentation at php.net...

When I try to include files using the standard line:

<?php
include("filesomewhere.php");
?>
'

it will find the file just fine if it is within that directory or any subdirectory of that one.

However, when I have a list of files like this:

Quote:
/WebDirectory/Apache2/htdocs/WebsiteName/SubDirectory/index.php
/WebDirectory/Apache2/htdocs/WebsiteName/SubDirectory/header.php
/WebDirectory/Apache2/htdocs/WebsiteName/SubDirectory2/login.php

If I want to include login.php in index.php, and I use a code like this:

<?php
// Index File
include("/WebsiteName/Subdirectory2/login.php");
?>
'

it does not work. This would work on any web host I have used, but locally, I am getting nothing. Any ideas? Is there something I need to change the include_path to in my php.ini? I can't quite figure it out.

Kurtis

He has: 698 posts

Joined: Jul 2005

I solved the index file problem. For anyone else as dumb as me on this, you may need to specify the following in your httpd.conf file in Apache:

DirectoryIndex index.html, index.htm, index.php
'

As far as the includes go, I simply gave up trying and gave the full path, like this:

include("C:/WebDirectory/...");
'

This will only be on my computer, which only I have access to, so once I upload it I can change them back.

Kurtis

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.