Jump to content

Index file not recognized and Includes


Recommended Posts

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:

 

/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.

Link to comment
Share on other sites

if index.html and index.htm is not working then this leads me to believe that you don't have Indexes enabled within the httpd.conf. To check see if Indexes is listed within the Options directive for the document root, should be around line 190 within the httpd.conf. If its not set with the Options directive append Indexes.

 

You will also want to set up your index files by adding them to the DirectoryIndex as thrope suggested above.

 

After you have made any changes save the httpd.conf and restart Apache. Go back to http://localhost/ and Apache should now be serving index files automatically if the directory you are in actually has an index file.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.