[Solved]Opening the directory instead of the index.php file?

Problems with the Windows version of XAMPP, questions, comments, and anything related.

[Solved]Opening the directory instead of the index.php file?

Postby kaitco » 08. November 2009 04:59

Up until recently, I have used phpdev to be able to test my .php files without having to add them to the server first. As it does not look like phpdev is being supported, I have switched to XAMPP which suits me even better than phpdev, but I was wondering if there was a way to change how it opens directories.

With phpdev, when going to http://localhost/public/My Webs/, I am able to see the full directory, regardless if there is an index file present.
Here is an example of what I mean:
Image
In XAMPP, however, going to a particular directory will open the index file if one is available as one would normally see if the files were on the public server. I was wondering if there was a way to mimic what I had what phpdev where opening the directory will show the directory files regardless if an index file is present.

Many thanks!
Last edited by kaitco on 08. November 2009 08:42, edited 2 times in total.
kaitco
 
Posts: 4
Joined: 07. November 2009 18:48

Re: Opening the directory instead of the index.php file?

Postby Izzy » 08. November 2009 05:47

You can but then you would need to specify your index file in the URI when ever you needed to.

This can be achieved in the \xampp\apache\conf\httpd.conf file.

Always make a Copy of any conf or ini files before editing and restart Apache after you finish editing so Apache can read the new data.

Find these line around 245 in XAMPP 1.7.2
Code: Select all
#
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
<IfModule dir_module>
    DirectoryIndex index.php index.pl index.cgi index.asp index.shtml index.html index.htm \
                   default.php default.pl default.cgi default.asp default.shtml default.html default.htm \
                   home.php home.pl home.cgi home.asp home.shtml home.html home.htm
</IfModule>
Comment out the whole section like so
Code: Select all
#
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
#<IfModule dir_module>
#    DirectoryIndex index.php index.pl index.cgi index.asp index.shtml index.html index.htm \
#                   default.php default.pl default.cgi default.asp default.shtml default.html default.htm \
#                   home.php home.pl home.cgi home.asp home.shtml home.html home.htm
#</IfModule>
Try that and see if it is what you are trying to do.

Good luck.
Izzy
 
Posts: 3344
Joined: 25. April 2006 17:06

Re: Opening the directory instead of the index.php file?

Postby kaitco » 08. November 2009 06:34

Thank you!

I tried what you suggested and it works for the first directory eg: http://localhost/My Webs/, but for any of the subdirectories beyond that (http://localhost/My Webs/media/), it still opens the index file.

Any thoughts?
kaitco
 
Posts: 4
Joined: 07. November 2009 18:48

Re: Opening the directory instead of the index.php file?

Postby Izzy » 08. November 2009 06:39

Try deleting your browser's cache and do that often when working at the localhost level.

Also check that you don't have an overriding .htaccess file in that folder.

BTW could you please reduce the size of your screen cap image.
Thanks
Izzy
 
Posts: 3344
Joined: 25. April 2006 17:06

Re: Opening the directory instead of the index.php file?

Postby kaitco » 08. November 2009 07:07

I must be still doing something wrong because I have cleared the cache (now, several times) and restarted Apache twice, but I am still running into the same problem. I do not have any .htaccess files in any of the subdirectories.

I am just not sure why one directory would work, but not the others. Would there be anything else that needed to be edited in that folder to pertain the subdirectories?

Edit: I tested other subdirectories by creating new index files where there was none previously and I get the directory listing for the new folders, but not folders where there was an index file before I had installed XAMPP.

Edit 2: In my tests of the other subdirectories, I found that if an index.html file is present, it will display rather than the directory listing, but as long as there are only index.php files in the directory, I am able to see the listing. Is there a way to configure this so that the directory listing will display regardless of any index file?
kaitco
 
Posts: 4
Joined: 07. November 2009 18:48

Re: Opening the directory instead of the index.php file?

Postby Izzy » 08. November 2009 07:44

Thanks for resizing the image as most members or those viewing the post hate to have to use horizontal scrolling.


Leave the edits you made in the httpd.conf file so that you can revert to a default file if at some time in the future you need these index files reinstating.

Directly under under the commented out section you made add this:
Code: Select all
<IfModule dir_module>
    DirectoryIndex noindex.noindex
</IfModule>

Save the file and restart Apache.

Now try again and see if that fixes the sub-directory issue.

What we have done is to sort of trick Apache into looking for a non existent index file which it will not find and so will now show the directory listing.

Good luck again.
Izzy
 
Posts: 3344
Joined: 25. April 2006 17:06

Re: Opening the directory instead of the index.php file?

Postby kaitco » 08. November 2009 08:41

Outstanding! That worked perfectly. Thank you very much!
kaitco
 
Posts: 4
Joined: 07. November 2009 18:48


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 93 guests

cron