How-to exclude a specific folder from global redirection using rewrite rules in your htaccess.

Here is what I want to do: index.html should be the only file visible. Every folder or files should be hidden using .htaccess. That’s all.

It’s something easy in fact, here’s the instruction to redirect any visitor coming from somewhere else than you index (deep link / folders / sub-folders / files…):

RewriteEngine on
RewriteRule !^wp($|/) http://mywebsite.com%{REQUEST_URI} [L,R=301]

But, I need to access a specific folder. Instead of creating exceptions in your very first .htaccess file located in the root folder, use another one to send new instructions. So here’s the deal, put this .htaccess in your folder, it’ll be visible and you’ll not be redirected:

RewriteEngine off
Written on August 4, 2017