I have a .htaccess file where I want to deny access from all DIR's except the folders in /docs/
that are called r20
or r21
, and I will want to add more DIR's in the future where they will start with r. What regex expression can I use? Thanks.
RewriteEngine On
<DirectoryMatch "^/docs/r">
Order deny,allow
Deny from all
</DirectoryMatch>
Thanks to @CBroe's suggestion, this works for me.
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/docs/r
RewriteRule !^/docs - [F]