33

I have the following .htaccess line, simple no indexes on root.

Options -Indexes

What do we add so it propagates to any sub directory instead of having to create one file for each? One .htaccess on root only.

Codex73
  • 5,690
  • 11
  • 56
  • 76

2 Answers2

41

The correct answer is

Options -Indexes

You must have been thinking of

AllowOverride All

https://httpd.apache.org/docs/2.2/howto/htaccess.html

.htaccess files (or "distributed configuration files") provide a way to make configuration changes on a per-directory basis. A file, containing one or more configuration directives, is placed in a particular document directory, and the directives apply to that directory, and all subdirectories thereof.

Davy M
  • 1,697
  • 4
  • 20
  • 27
oasisfleeting
  • 999
  • 12
  • 6
30

htaccess files affect the directory they are placed in and all sub-directories, that is an htaccess file located in your root directory (yoursite.com) would affect yoursite.com/content, yoursite.com/content/contents, etc.

http://www.javascriptkit.com/howto/htaccess.shtml

Kaleb Brasee
  • 51,193
  • 8
  • 108
  • 113
  • 12
    Actually it does, just tested it. Even without ALL it applies to sub folders! – php_nub_qq Jun 09 '13 at 18:20
  • 6
    @Codex73, Kaleb is right: .htaccess ["directives apply to that directory, and all subdirectories"](http://httpd.apache.org/docs/current/howto/htaccess.html#what). – Michał Powaga Jul 28 '13 at 18:39