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

Share:
5,696

Related videos on Youtube

Admin
Author by

Admin

Updated on September 18, 2022

Comments

  • Admin
    Admin almost 2 years

    With no .htaccess files and Options FollowSymLinks MultiViews Indexes followed by AllowOverride 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
    CaptainStiggz about 11 years
    That made no difference. I renamed the only .htaccess file I had to be certain.
  • dan
    dan about 11 years
    It 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
    dan about 11 years
    Take a look at the first answer here: serverfault.com/questions/232949/…
  • CaptainStiggz
    CaptainStiggz about 11 years
    It 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
    dan about 11 years
    Hmmm...I take it you can serve files from the directory OK, but just not list them? (Checking the modules I have installed)...
  • dan
    dan about 11 years
    I 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
    dan about 11 years
    Yes, 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
    dan about 11 years
    Updated. Good luck!