简体   繁体   English

PHP / Apache,htaccess中的选项+索引不适用于根目录

[英]PHP/Apache, options +indexes in htaccess doesn't work for root directory

I need to offer a directory listing of the root directory of my site, so I created an .htaccess file containing 我需要提供我的站点根目录目录列表 ,所以我创建了一个包含的.htaccess文件

options +indexes

It works for subdirectories, but for the main directory I get the Test Page for the Apache HTTP Server on Red Hat Enterprise Linux page. 它适用于子目录,但是对于主目录,我在Red Hat Enterprise Linux页面上获得了Apache HTTP Server测试页面。

I have two sites that are identical except for the PHP version installed. 除了安装的PHP版本之外,我有两个相同的站点。 On one site ( PHP 5.2.1 ) this technique works fine. 在一个站点( PHP 5.2.1 )上,这种技术工作正常。 On the other ( PHP 5.2.9 ), it doesn't. 另一方面( PHP 5.2.9 ),它没有。

As far as I know, the Apache installations are identical, and I verified that the httpd.conf files are identical . 据我所知, Apache安装是相同的,我验证了httpd.conf文件是相同的

On both sites, the htaccess works for subdirectories. 在这两个站点上,htaccess适用于子目录。 My problem is with the main site directory. 我的问题是主站点目录。

My goal is to create simple sites based on directory listings, similar to znvy.com . 我的目标是基于目录列表创建简单的站点,类似于znvy.com

Is there something about the updated PHP version that prevents listing a root directory ? 有没有关于更新的PHP版本,以防止列出根目录 If so is there a workaround ? 如果有的话有解决方法吗?

[update] I looked at the page using rex swain's http viewer and the server of the problem site is returning a 403 status with the Apache default page. [更新]我使用rex swain的http查看器查看了该页面,问题站点的服务器返回了一个带有Apache默认页面的403状态。

The problem was being caused by the /etc/httpd/conf.d/welcome.conf file: 问题是由/etc/httpd/conf.d/welcome.conf文件引起的:

Options -Indexes
    ErrorDocument 403 /error/noindex.html

That file overrides the htaccess and turns indexing off for any root web directory. 该文件会覆盖htaccess,并为任何根网站目录关闭索引。 Renaming it to welcome.con and restarting the server solved the problem. 将它重命名为welcome.con并重新启动服务器解决了这个问题。

Does your main directory have an index.html or index.php file? 您的主目录是否有index.html或index.php文件? I believe +Indexes only shows if a default document doesn't exist in the directory. 我相信+索引只显示目录中是否存在默认文档。

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

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