How can I disable directory browsing in apache

Discussion in 'General' started by arastirici, Sep 28, 2011.

  1. arastirici

    arastirici New Member

    Hello

    I use ispconfig2 on opensuse11.1, apache,php5 work on it.
    it works well But. directory indexes is enable. I can't disable it ?

    cat /etc/apache2/httpd.conf;

    <Directory /wwwroot1/*/web>
    Options -Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    Order allow,deny
    Allow from all
    <Files ~ "^\.ht">
    Allow from all
    </Files>
    </Directory>

    How can I disable directory browsing in apache ?

    Thanks
     
  2. falko

    falko Super Moderator Howtoforge Staff

    Did you set
    Code:
    Options -Indexes
    in the correct vhost? Did you check if there's maybe an .htaccess file where directory indexes are enabled?
     
  3. arastirici

    arastirici New Member

    for example, a vhost is located in /wwwroot1/web106

    I added .htaccess file to web106/web/
    and if I put down it " IndexIgnore */* " , it works
    But if I put down Options -Indexes I get internal server error.

    and it gets an error message;
    .htaccess: Options not allowed here

    I can't see any configure that it is enable +indexes
    Also Allowoverride is All

    What could be the problem ?
     
  4. falko

    falko Super Moderator Howtoforge Staff

    I guess you set
    Code:
    Options -Indexes
    and
    Code:
    AllowOverride All
    in the wrong locations. I'd set these in <Directory> containers inside your vhost.
     
  5. arastirici

    arastirici New Member

    Hello

    the apache server doesn't allow me to configure "Allowoverride All" into vhost ( onto ispconfig control panel )
    Therefore I configured "Allowoverride All" into /etc/apache2/httpd.conf

    Note: I use opensuse11.1 and ispconfig2
     
  6. falko

    falko Super Moderator Howtoforge Staff

    You can use the Apache Directives field on the Options tab in ISPConfig.
     
  7. arastirici

    arastirici New Member

    These apache directives in options tab of ispconfig works but Options -indexes does not work.

    That's very interesting. i think it is a bug.
     
  8. falko

    falko Super Moderator Howtoforge Staff

    What exactly did you put in the Apache Directives field?
    Did you wrap <Directory ...></Directory> around the Options line?
     
  9. arastirici

    arastirici New Member

    I put down as following in ispconfig's apache directives;

    <Directory /wwwroot1/web167/web>
    Options -Indexes
    </Directory>

    I get an internal server error.

    if I put down "IndexIgnore */*" in .htaccess
    it works.
     
  10. falko

    falko Super Moderator Howtoforge Staff

    And there's nothing in Apache's error logs?
     
  11. arastirici

    arastirici New Member

    I get an error in web170/log/error.log as below

    .../web170/web/content/.htaccess: Options not allowed here

    and I get man errors in /var/log/apache2/error_log
    # tail -f /var/log/apache2/error_log
    [Mon Oct 03 21:29:46 2011] [error] an unknown filter was not added: PHP
     
  12. nenad

    nenad Member

    I have similar problem (never happened before).
    When I go to with browser the server ip address (or corresponding domain name ) instead of usual "It works" I get directoy listing.

    Where should I disable directoy listing?

    apache2 conflig looks like:

    /etc/apache2/httpd.conf

     
  13. falko

    falko Super Moderator Howtoforge Staff

    Check the default vhost configuration (it's in /etc/apache2/sites-available/default).
     

Share This Page