简体   繁体   English

.htaccess选项-索引

[英].htaccess Options -Indexes

I'm using a simple .htaccess file with the contents 我正在使用带有内容的简单.htaccess文件

Options -Indexes 选项-索引

to try and hide directory listings. 尝试隐藏目录列表。 However, when I try to load any page from the browser it gives me a 403 error for any page. 但是,当我尝试从浏览器加载任何页面时,任何页面都会出现403错误。 Any ideas what the problem is? 任何想法是什么问题?

For context, .htaccess is in the root folder that contains php files and folders of other php files included/required etc. by those in root. 对于上下文,.htaccess位于根目录中,该目录包含php文件以及根目录中包含/需要的其他php文件等文件夹。

Thanks in advance 提前致谢

Ben

Make sure that you have a proper directory index setting. 确保您具有正确的目录索引设置。 The Indexes option simply tells apache to display the contents of the directory as the index if there isn't a default index in that directory. 如果该目录中没有默认索引,则Indexes选项只是告诉apache将目录的内容显示为索引。

So if you have the file: 因此,如果您有文件:

/index.php

Make sure you have: 确保您具有:

  1. A valid index file 有效的索引文件
  2. it is part of the list defined by DirectoryIndex 它是DirectoryIndex定义的列表的一部分
  3. It is readable by apache. apache可读。

If your index.php is the file you want serves when the request is for the directory, then make sure it is readable by apache (644 is good enough ), then make sure it's in the list defined by the directory index: 如果index.php是在请求目录时要提供的文件,请确保apache可以读取它(644 足够好 ),然后确保它在目录索引定义的列表中:

DirectoryIndex index.php

One other thing that may be happening, and it's very specific to someone's website setup. 可能正在发生的另一件事,它非常特定于某人的网站设置。 If you have DirectorySlash Off somewhere, meaning apache won't automatically redirect the browser when a trailing slash is missing when a reqeust is for a directory, and you have Indexes turned off, then your index file will get ignored . 如果您在某处DirectorySlash Off ,则意味着当对目录的要求不足时,如果缺少尾部斜杠,并且Indexes已关闭,则apache不会自动重定向浏览器,那么您的索引文件将被忽略

Example, if I have directory slash off, and a request for the directory is made: 例如,如果我有目录斜杠,并且请求目录:

/folder

without the trailing slash, it doesn't matter if you have a valid index file, it will get ignored without a trailing slash . 如果没有有效的索引文件, 没有尾部的斜杠,而没有尾部的斜杠,它将被忽略 If this is the case, make sure you really want to have trailing slashes removed for accesses to directories and this is a limitation of apache. 如果是这种情况,请确保您确实要删除用于访问目录的结尾斜杠,这是apache的限制。

I had this problem and it was due to permissions. 我有这个问题,这是由于权限。 CHMOD it to 777 or whatever. 将其更改为777或其他任何值。

Also, consider this rule is run for each page load. 另外,请考虑针对每个页面加载运行此规则。 For speed purposes you can create .htaccess for each folder. 为了提高速度,您可以为每个文件夹创建.htaccess。

也许您的文件夹权限,应该检查一下

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM