Allow subdirectory with Apache

apache-2.2directory

I feel like this is a fairly simple fix and have seen similar problems when searching but haven't been able to fix it with those solutions. Basically the problem is I cannot access any subdirectories on my webserver. Going to localhost brings up the index fine. But going to localhost/test gives a 403 Forbidden error.

I'm running CentOS. I've tried editing the /etc/httpd/conf/httpd.conf file a couple of ways but have had no luck. The DocumentRoot is located at /var/www/html. Currently I have:

<Directory />
    Options FollowSymLinks
    AllowOverride None
</Directory>

<Directory "/var/www/html">
    Options Indexes FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

I've tried adding the following:

<Directory "/var/www/html/test">
    Order allow,deny
    Allow from all
</Directory>

But it still gives me the 403 forbidden error.

Best Answer

You should not need to specifically allow access to a directory below one which is already configured within httpd.conf

Since /var/www/html is configured with "AllowOverride None" then the problem is not due a .htaccess file changing the access rights.

The only remaining reason is that the permissions on the files and directories do not permit the webserver uid to read from this directory. What they are, and what they should be depends on your security model. But as a quick fix you could try:

# chmod a+rx /var/www/html/test
# chmod a+r /var/www/html/*

If this solves the problem then please take time to fix the ownership and permissions of the files to something more appropriate.