zimmandrew Posted July 21, 2007 Share Posted July 21, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/61046-index-file-not-recognized-and-includes/ Share on other sites More sharing options...
trq Posted July 21, 2007 Share Posted July 21, 2007 1. make sure your httpd.conf file has a line like... DirectoryIndex index.php index.html 2. <?php include $_SERVER['DOCUMENT_ROOT'] . "/WebsiteName/Subdirectory2/login.php"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/61046-index-file-not-recognized-and-includes/#findComment-303943 Share on other sites More sharing options...
wildteen88 Posted July 21, 2007 Share Posted July 21, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/61046-index-file-not-recognized-and-includes/#findComment-304029 Share on other sites More sharing options...
zimmandrew Posted July 21, 2007 Author Share Posted July 21, 2007 Thanks! Both of those things worked great. ;-) For some reason, the DirectoryIndex portion had nothing specified, so I added index.htm, index.html, and index.php to it. The includes work fine that way too. ;-) Quote Link to comment https://forums.phpfreaks.com/topic/61046-index-file-not-recognized-and-includes/#findComment-304057 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.