Apache 2.4,在浏览器中启用文件夹视图

Ton*_*old 5 php windows apache

在Apache Lounge的Win 7机器上使用Apache 2.4 64位VC10构建,如何启用文件夹文件视图?我只想查看该文件夹中没有索引文件的每个文件夹中的文件.

这仅用于开发目的.我尝试过使用Options Indexes/All选项并重启我的服务器几次.我得到的只是403 Forbidden.

Bra*_*ady 6

对于Apache 2.4,如果已启用目录索引(如index.html或index.php),则必须首先禁用该索引,然后才能在Web浏览器中显示文件夹和文件.

<Directory "/vhost/www/htdocs/path/to/folder">
 DirectoryIndex disabled
 Options Indexes
</Directory>
Run Code Online (Sandbox Code Playgroud)


Kyl*_*ots 5

Apache 中的指令已从 2.2 版更改为 2.4 版及更高版本。

我正在运行 2.4.7 版,一个基本的 vhost 文件如下所示:

<VirtualHost 192.168.1.5:80>

  DocumentRoot /srv/html/
  ServerName some.placeoverthe.rainbow

 <Directory /srv/html/>
   Options Indexes  ## Allows directory browsing.
   Require all granted  ## Allow all request
 </Directory>

</VirtualHost>
Run Code Online (Sandbox Code Playgroud)

取自 Apache 网站:https : //httpd.apache.org/docs/2.4/upgrading.html

以下是执行相同访问控制的新旧方法的一些示例。

在本例中,所有请求都被拒绝。

2.2 配置:

Order deny,allow
Deny from all
Run Code Online (Sandbox Code Playgroud)

2.4 配置:

Require all denied
Run Code Online (Sandbox Code Playgroud)

在此示例中,允许所有请求。

2.2 配置:

Order allow,deny
Allow from all
Run Code Online (Sandbox Code Playgroud)

2.4 配置:

Require all granted
Run Code Online (Sandbox Code Playgroud)

在下面的例子中,example.org 域中的所有主机都被允许访问;所有其他主机都被拒绝访问。

2.2 配置:

Order Deny,Allow
Deny from all
Allow from example.org
Run Code Online (Sandbox Code Playgroud)

2.4 配置:

Require host example.org
Run Code Online (Sandbox Code Playgroud)

目录索引

取自 Apache 网站:http : //httpd.apache.org/docs/2.4/mod/core.html

Options 指令控制特定目录中可用的服务器功能。

选项可以设置为无,在这种情况下,不启用任何额外功能,或以下一项或多项:

全部

  All options except for MultiViews.
Run Code Online (Sandbox Code Playgroud)

执行CGI

  Execution of CGI scripts using mod_cgi is permitted.
Run Code Online (Sandbox Code Playgroud)

关注符号链接

服务器将遵循此目录中的符号链接。这是默认设置。

即使服务器遵循符号链接,它也不会更改用于匹配部分的路径名。

FollowSymLinks 和 SymLinksIfOwnerMatch 选项仅适用于部分或 .htaccess 文件。

省略此选项不应被视为安全限制,因为符号链接测试受竞争条件的影响,使其可以规避。

包括

Server-side includes provided by mod_include are permitted.
Run Code Online (Sandbox Code Playgroud)

包括NOEXEC

Server-side includes are permitted, but the #exec cmd and #exec cgi are disabled. It is still possible to #include virtual CGI scripts from ScriptAliased directories.
Run Code Online (Sandbox Code Playgroud)

索引

如果请求映射到目录的 URL 并且该目录中没有 DirectoryIndex例如index.html),则mod_autoindex将返回该目录的格式化列表。

多视图

允许使用 mod_negotiation 协商内容“MultiViews”。

注意: 如果设置为
以外的任何地方,则此选项将被忽略,因为mod_negotiation 需要实际资源来进行比较和评估。

符号链接如果所有者匹配

The server will only follow symbolic links for 
which the target file or directory is owned by 
the same user id as the link. 
Run Code Online (Sandbox Code Playgroud)

附带说明:您可能需要检查并确保运行 apache 的用户有权从该目录读取。在 Windows 上,这可能不是问题,但在 Linux 上,这可能是一个问题。在大多数 Linux 发行版中,默认用户通常是:

万维网数据

因此,如果该目录的所有者不是 apache 运行的用户,则您需要更改该目录的权限以允许 apache 访问。


hak*_*kre 1

<Directory "/srv/www/htdocs"> 
        Options +Indexes
        ################
        Order allow,deny 
        Allow from all 
</Directory>
Run Code Online (Sandbox Code Playgroud)