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
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.
I have two sites that are identical except for the PHP version installed. On one site (PHP 5.2.1) this technique works fine. On the other (PHP 5.2.9), it doesn't.
As far as I know, the Apache installations are identical, and I verified that the httpd.conf files are identical.
On both sites, the htaccess works for subdirectories. My problem is with the main site directory.
My goal is to create simple sites based on directory listings, similar to znvy.com.
Is there something about the updated PHP version that prevents listing a root directory? 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.
The problem was being caused by the /etc/httpd/conf.d/welcome.conf file:
Options -Indexes ErrorDocument 403 /error/noindex.html
That file overrides the htaccess and turns indexing off for any root web directory. Renaming it to welcome.con and restarting the server solved the problem.
Does your main directory have an index.html or index.php file? I believe +Indexes only shows if a default document doesn't exist in the directory.
精彩评论