Apache - directory browsing gives 404
5,696
Try using this under <Directory>
AllowOverride All
And make sure there isn't a .htaccess file that disables directory browsing in the directory that you're making the request to (and restart Apache).
Update:
Make sure that the mod_autoindex
module is loaded along with the mod_dir
module. Without the former, you'll get an error when browsing directories. See this:
Apache Module mod_autoindex
Related videos on Youtube
![Admin](/assets/logo_square_200-5d0d61d6853298bd2a4fe063103715b4daf2819fc21225efa21dfb93e61952ea.png)
Author by
Admin
Updated on September 18, 2022Comments
-
Admin almost 2 years
With no .htaccess files and
Options FollowSymLinks MultiViews Indexes
followed byAllowOverride None
in the vhost configuration, I'm getting 404 responses from directory listings. Are there some specific modules I need for directory listings?My active modules are:
- authz_host
- deflate
- dir
- env
- expires
- headers
- mime
- mod-security
- negotiation
- php5
- reqtimeout
- rewrite
- setenvif
- ssl
- unique_id
VHost Configuration:
<VirtualHost *:443> # SSL SSLEngine On SSLCertificateKeyFile /dir/ssl/ssl.key SSLCertificateFile /dir/ssl/ssl.crt SSLSessionCacheTimeout 300 </VirtualHost> <VirtualHost *:80 *:443> ServerAdmin webmaster@localhost ServerAlias domain.tld *.domain.tld ServerName cl.domain.tld # Just a few connection resets so that I don't waste my bandwidth on "hackers" SecRuleEngine On SecRule &REQUEST_HEADERS:User-Agent "@eq 0" drop,phase:1 SecRule REQUEST_HEADERS:User-Agent "^$" drop,phase:1 SecRule REQUEST_LINE "://" drop,phase:1 SecRule REQUEST_URI "^/admin" drop,phase:1 SecRule REQUEST_URI "^/mail" drop,phase:1 SecRule REQUEST_URI "^/webmail" drop,phase:1 SecRule REQUEST_URI \\\\ drop,phase:1 SecRule REQUEST_METHOD !^GET$ chain,drop,phase:1 SecRule REQUEST_METHOD !^HEAD$ chain SecRule REQUEST_METHOD !^POST$ <Directory /dir/public_html/> Options FollowSymLinks MultiViews Indexes Order allow,deny allow from all </Directory> DocumentRoot /dir/public_html </VirtualHost>
-
CaptainStiggz about 11 yearsThat made no difference. I renamed the only .htaccess file I had to be certain.
-
dan about 11 yearsIt was just a shot, copied from an Apache vhost with working directory listing. From what I can see, you have the correct options, unless a .htaccess file is overriding it, which you say isn't the case.
-
dan about 11 yearsTake a look at the first answer here: serverfault.com/questions/232949/…
-
CaptainStiggz about 11 yearsIt was worth a shot. Did you only have the modules I have enabled? I think that might be the issue. I also listed my entire VHost configuration. I even did a grep for "options" and saw no "-Indexes" @dan
-
dan about 11 yearsHmmm...I take it you can serve files from the directory OK, but just not list them? (Checking the modules I have installed)...
-
dan about 11 yearsI have this loaded, missing from your list: mod_autoindex. See the docs about it here: httpd.apache.org/docs/current/mod/mod_autoindex.html
-
dan about 11 yearsYes, I confirmed it to on my end too by disabling it. Glad I was able to help. I'll edit my answer now. Thanks for the accept!
-
dan about 11 yearsUpdated. Good luck!