Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

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|improve this answer
    
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. –  Jakobud Jan 16 '12 at 22:50
    
@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)? –  Shane Madden Jan 16 '12 at 22:54
    
Ah yes I believe AllowOverride None was set in the httpd.conf. Thanks! –  Jakobud Jan 17 '12 at 16:49

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.