apache .htaccess 文件选项 - 子目录上的索引

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1767785/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 18:25:07  来源:igfitidea点击:

.htaccess File Options -Indexes on Subdirectories

apache.htaccessapache2

提问by Codex73

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

我有以下 .htaccess 行,简单的 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.

我们要添加什么才能传播到任何子目录,而不必为每个子目录创建一个文件?一个 .htaccess 只在 root 上。

回答by oasisfleeting

The correct answer is

正确答案是

Options -Indexes

You must have been thinking of

你一定想过

AllowOverride All

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

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.

.htaccess 文件(或“分布式配置文件”)提供了一种在每个目录的基础上进行配置更改的方法。包含一个或多个配置指令的文件被放置在特定的文档目录中,这些指令适用于该目录及其所有子目录。

回答by Kaleb Brasee

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.

htaccess 文件会影响它们所在的目录和所有子目录,即位于根目录 (yoursite.com) 中的 htaccess 文件会影响 yoursite.com/content、yoursite.com/content/contents 等。

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

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