Apache Config Trick: A Special Directory
21 Jun 2007
So say you need to require users to enter their username and password before they can get content from your Apache server? Well, that’s easy:
<Location "/"> AuthType ... AuthName... Require valid-user ... </Location>
But what if you want to have one special directory where you don’t want to authenticate users? Extended regular expressions to the rescue (perldoc perlre)! Just change the first line in above code:
from
<Location "/">
to
<Location ~ "^/(?!special)">
Now authentication will be required for everything but /special.