Apache: How to deny access to a parent directory/location only

If you want to deny public access to a parent location (let’s say /projects/), but allow public access to a sub-location (/projects/myproject/), use the following statement in httpd.conf:

<Location /projects>Order allow,deny</Location>
<Location /projects/myproject>Order deny,allow</Location>

(can also be used for <Directory> statements etc.)

Note that the URL of the sub-location must include a trailing slash (e.g. “https://news.numlock.ch/projects/myproject/”)

One Reply to “Apache: How to deny access to a parent directory/location only”

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.