Apache Config Trick: A Special Directory

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 ...
Require valid-user

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:


<Location "/">


<Location ~ "^/(?!special)">

Now authentication will be required for everything but /special.

Categories: linux |