Apache: Options +Indexes still results in 403 Forbidden or Apache Test Page

8,191

Sure, AllowOverride None would prevent .htaccess files from functioning. But, why use them at all? Apache's recommendation is to never use .htaccess unless you are unable to access the main configuration.

Try this, instead:

<VirtualHost *:80>
  ServerAdmin no-reply@localhost
  ServerName sandbox.mysite.internal
  DocumentRoot /var/www/vhosts/sandbox/mysite
  ErrorLog logs/sandbox/mysite-error.log
  CustomLog logs/sandbox/mysite-access.log common
  <Directory /var/www/vhosts/sandbox/mysite/test/>
    Order allow,deny
    Allow from all
    Options +Indexes
  </Directory>
</VirtualHost>

If that doesn't work, have a look at Apache's error log; you may have something wrong with your file/directory permissions, for example.

Share:
8,191

Related videos on Youtube

Jake Wilson
Author by

Jake Wilson

Updated on September 18, 2022

Comments

  • Jake Wilson
    Jake Wilson almost 2 years

    On a local dev server, I have an Apache conf for a website like so

    <VirtualHost *:80>
      ServerAdmin no-reply@localhost
      ServerName sandbox.mysite.internal
      DocumentRoot /var/www/vhosts/sandbox/mysite
      ErrorLog logs/sandbox/mysite-error.log
      CustomLog logs/sandbox/mysite-access.log common
    </VirtualHost>
    

    If I visit the following address (there is no index.php or index.html)

    http://sandbox.mysite.internal
    

    I get the Apache CentOS test page

    If I visit a subdirectory like

    http://sandbox.mysite.internal/test/
    

    I get a 403 Forbidden error. So I add the following .htaccess here:

    /var/www/vhosts/sandbox/mysite/test/.htaccess
    

    Content:

    Options +Indexes
    

    Now when I visit:

    http://sandbox.mysite.internal/test/
    

    I still get 403 Forbidden.

    How do I make the directory index show up?

    I always thought .htaccess directives override any httpd.conf directives. But am I wrong about that? Is there some setting in my httpd.conf that is making my .htaccess directive be ignored?

  • Jake Wilson
    Jake Wilson over 12 years
    That worked perfectly. Thanks! The only reason I was using the .htaccess is because it's convenient to add/remove that file at will to make quick adjustments, even if temporary.
  • ravi yarlagadda
    ravi yarlagadda over 12 years
    @Jakobud Gotcha - and that's just fine for a development/sandbox environment. Well, if that worked, then it was either the Order and Allow directives that I added in the Directory block, or else you do indeed have an AllowOverride None, or perhaps an AccessFileName changing the name from the default (.htaccess)?
  • Jake Wilson
    Jake Wilson over 12 years
    Ah yes I believe AllowOverride None was set in the httpd.conf. Thanks!
  • Kotlopou
    Kotlopou almost 3 years
    How would this look for Apache 2.4?