homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

Re. Can htaccess restore default indexing

 2:21 pm on Oct 20, 2010 (gmt 0)

Sometimes we prevent folders from showing a list of the files they contain: using IndexIgnore in htaccess.

However sometimes I need indexing to be allowed in a sub-folder e.g. to show a list of documents for download. Does anyone know if there is an htaccess command to restore indexing for a subfolder?

By 'Indexing' I mean the way a browser shows the list of files in a folder when there is no default page like index.html



 6:29 pm on Oct 20, 2010 (gmt 0)


Options +Indexes


 11:54 am on Oct 24, 2010 (gmt 0)

I tried, it didn't work. Have I got the syntax wrong?
I first tried adding another .htaccess file in the relevant subfolder (called 'presentation') with just: Options +Indexes
Then I tried adding the following instead to the root .htaccess: Options +Indexes /presentation
None of the above worked, the folder 'presentation' will not show an index list of its files.


 1:42 pm on Oct 26, 2010 (gmt 0)

So is this impossible?


 2:22 pm on Oct 26, 2010 (gmt 0)

Once you setup IndexIgnore you cannot override it from the sub-folders. Try using order allow,deny for it.


 2:34 pm on Oct 26, 2010 (gmt 0)

It's likely that you can't use one kind of directive to override the action of a different kind of directive.

Try replacing the "IndexIgnore" directive in your top-level .htaccess file with "Options -Indexes". Then override it in your lower-level .htaccess file(s) with "Options +Indexes" where you want to enable directory-index-list generation.

Note that "Options" does not take URL-paths or directory-paths as arguments. It supports only those options listed in the Apache core "Options" documentation.

Further, using "Options" in .htaccess files requires that "AllowOverride Options" or "AllowOverride All" be set in the server configuration file. Although this is generally not accessible on shared hosting, most servers are configured to support "Options."

The "IndexIgnore" and "Options -Indexes" do not work in exactly the same way, so be sure that you test thoroughly if you make these changes, to be sure that the response for directory-index requests when directory indexes are NOT allowed is acceptable to you -- "Options -Indexes" will invoke a 403-Forbidden response to such requests if there is not "index page" present in the requested directory. The list of defined index pages is in turn set by the DirectoryIndex directive, and generally includes most "common" index page filenames such as index.html index.htm, index.php, and sometimes "default.html" and other common variations. On most servers, you can change the DirectoryIndex settings in .htaccess if you wish.

I strongly suggest that you look up each Apache directive that you intend to use at apache.org; In addition to learning the correct syntax for each directive, many have "side effects" that you need to know about. Keep in mind that .htaccess files are server configuration files, and server configuration is not something to be "toyed with." In addition, consider the effects of your settings on search-engine robot accessibility, indexing, and ranking.



 3:44 pm on Nov 23, 2010 (gmt 0)

Thanks! This works perfectly :)
To summerise:
- in site root put this in htaccess: "Options -Indexes" (prevents index list on root and sub folders),
- in folder where you need to allow an index list put this in htaccess file: "Options +Indexes"

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved