Reputation: 12562
I need to allow direct access on a specific folder name (and subcontents) via .htaccess, and deny all other.
To start, my current .htaccess
is:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]
My file structure is, for instance:
modules/
core/
_test/
publics/
file.txt
other/
_whatever/
publics/
more.txt
publics/
sub/
file.txt
other.txt
.htaccess
I could not access anything, except by files and folders that are in publics
folder. On this example, I could access, without problem:
I could not have access to any file or folder.
I guess that we will need regular expression, but I don't know how I can use this on mod_rewrite to works like I want.
Some suggestion?
Upvotes: 2
Views: 4810
Reputation: 856
A slight modification to your current htaccess. Any access not under a publics folder will be redirected to index.php:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !publics/
RewriteRule . index.php [L]
Upvotes: 4