Apache: Options +Indexes still results in 403 Forbidden or Apache Test Page
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.
Related videos on Youtube
Jake Wilson
Updated on September 18, 2022Comments
-
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 anyhttpd.conf
directives. But am I wrong about that? Is there some setting in myhttpd.conf
that is making my.htaccess
directive be ignored? -
Jake Wilson over 12 yearsThat 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 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
andAllow
directives that I added in theDirectory
block, or else you do indeed have anAllowOverride None
, or perhaps anAccessFileName
changing the name from the default (.htaccess
)? -
Jake Wilson over 12 yearsAh yes I believe
AllowOverride None
was set in thehttpd.conf
. Thanks! -
Kotlopou almost 3 yearsHow would this look for Apache 2.4?