Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.htaccess - How to deny all directories except one?

I have this structure:

 /folder/public/
 /folder/text.txt
 /folder/app/
 (etc...)

I want visitors to access to /public/ except everything else.

like image 867
Christopher Avatar asked Dec 04 '25 11:12

Christopher


1 Answers

You can use this rule in site root .htaccess:

RewriteEngine On

# block everything except /folder/public/
RewriteRule !^folder/public/ - [F,NC]
like image 111
anubhava Avatar answered Dec 07 '25 14:12

anubhava



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!