Options指令禁止的服务器生成的目录索引

时间:2016-08-12 20:54:45

标签: php apache .htaccess mod-rewrite

我知道这个问题已被问过很多次,但我找不到任何有帮助的答案。

所以我有两个页面,index.php和refer.php。我把一个规则放到我的httpd.conf中,当用户进入页面时,使用mod_rewrite去除.php扩展名。 Refer.php很好地显示为 refer ,但是尝试转到index.php会给我一个Forbidden错误。

错误日志显示:

AH01276: Cannot serve directory /var/www/html/: No matching DirectoryIndex (index.php,index.html) found, and server-generated directory index forbidden by Options directive.

这是我的httpd.conf的相关部分:

<Directory "/var/www">
    AllowOverride All
    # Allow open access:
    Require all granted
</Directory>

# Further relax access to the default document root:
<Directory "/var/www/html">
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.4/mod/core.html#options
    # for more information.
    #
    Options FollowSymLinks

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   Options FileInfo AuthConfig Limit
    #
    AllowOverride All

    #
    # Controls who can get stuff from this server.
    #
    Require all granted
</Directory>

文件index.php当然存在。有什么帮助吗?

编辑:

网址就是根网址 - 就像domain.com一样。它应该访问index.php,它在我做mod_rewrite之前做得很好。所以我希望索引页面出现,但由于我上面描述的错误,它没有。 .htaccess文件只是默认值,除了:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*) $1.php [L]

0 个答案:

没有答案