The forums have permanently moved to This forum will be kept around in read-only mode for archival purposes. To learn how to continue using your existing account on the new forums, check out this thread.

Results 1 to 5 of 5

Thread: Default Index

  1. #1

    Default Index

    Is it possible to have "open directories" (directories containing no index file) display a generic index.html/index.php/etc. by default? I'm working on a script now that will display all the contents of the local directory in a customized style and maybe offer a little extra functionality. I'm frequently adding folders to my webspace, and it would be convenient if anytime an "open directory" was encountered, it pointed to some generic index file stored elsewhere. This would eliminate the need for me to make a copy of this generic index.php every time I create a new directory.

  2. #2
    in your .htaccess you can do

    Options +Indexes
    Let us live so that when we come to die even the undertaker will be sorry. - Mark Twain
    Don't PM me your CSS, xHTML, JS or PHP questions. I will not reply to ANY IE6 questions.

  3. #3
    Thanks for the response, Simplistik.

    I did some research, though, and from what I could find out about "Options +Indexes", it seems that it only enables or disables the browsing of open directories by the traditional means.

    What I'm actually looking for is for any open directory to be automatically substituted with another index file. For example, say my folders/files are setup like this, with root representing the directory of


    The way it's currently setup, if you navigate to the root directory via web browser, you'll see index.html, pretty standard, and I'd like to keep it this way - there's an index available, so use it. If, however, you go to (where there is no index, you would either see the traditionally formatted open directory, listing the files (pic1.jpg, pic2.jpg, pic3.jpg) or if such browsing is disabled, I guess you would see nothing at all. What I'm trying to do is have the server say, "Oh, there's no index here in! I better resort to the default!", and then display defaults/genericindex.php.

    Hopefully I was coherent with all that. Do you think anything like this is possible?

  4. #4
    Well, I've discovered this little bit of code:

    DirectoryIndex index.html index.php index.txt /genericindex/index.php
    Now, if neither index.html, index.php nor index.txt exist in the local directory, genericindex/index.php is displayed. The only problem is that while the url in the address bar remains the same (it doesn't change to /genericindex/index.php), the script still pulls the contents of the /genericindex/ directory rather than the directory that was intended to be viewed.

  5. #5
    Got it!
    $_SERVER['REQUEST_URI'] was the key.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Home About Meet the Moderators Advertise

 Link to Us


Copyright 1999 - 2012