Welcome to WebmasterWorld Guest from 23.20.82.60

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Re. Can htaccess restore default indexing

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

Senior Member from GB 

WebmasterWorld Senior Member 10+ Year Member

joined:Feb 21, 2001
posts:1281
votes: 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)

Preferred Member

10+ Year Member

joined:Apr 7, 2003
posts:540
votes: 0


Try:

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

Senior Member from GB 

WebmasterWorld Senior Member 10+ Year Member

joined:Feb 21, 2001
posts: 1281
votes: 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)

Senior Member from GB 

WebmasterWorld Senior Member 10+ Year Member

joined:Feb 21, 2001
posts: 1281
votes: 0


So is this impossible?
2:22 pm on Oct 26, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member 5+ Year Member

joined:Apr 30, 2007
posts:1394
votes: 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)

Senior Member

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 31, 2002
posts:25430
votes: 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.

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

Senior Member from GB 

WebmasterWorld Senior Member 10+ Year Member

joined:Feb 21, 2001
posts: 1281
votes: 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"