Sam Pearson
Sam Pearson

Reputation: 69

.htaccess block hidden directories except one

I'm trying to allow access to a folder called .well-known but I've found this rule that blocks hidden directories;

# block hidden directories
RewriteRule "(^|/)\." - [F]

Obviously there's a reason why this was added (I inherited the code) but I was wondering if I could keep this rule but add an exception for the .well-known folder?

Upvotes: 3

Views: 1482

Answers (1)

Joe
Joe

Reputation: 4897

You can indeed! You need to include a Rewrite Condition:

RewriteCond %{REQUEST_URI} !^/\.well-known

Put this before the actual RewriteRule, this condition basically tells the server NOT to hide the .well-known folder.

Make sure you clear your cache before testing this.

Upvotes: 4

Related Questions