简体   繁体   中英

htaccess prevent direct access to path and override with another

There are two parts to my question...

A. What .htaccess should I place in a root folder, in order to prevent ALL DIRECT access to ALL sub-folders & files

B. After doing that, is there a way to place another .htaccess file inside a specific folder (within the root folder) in order to override the first root .htaccess rule

in example :

I would like to prevent all direct access to the blog sub-directories

blog/posts
blog/files

with a single .htaccess file placed in the root directory

But I still want the following to be accessible

blog/js
blog/css

using a specific .htacess file to be placed within each of those

Thanks!

update - I actually found an answer to A (deny from all), but still how can I override the deny from all placed in the root folder, with a specific .htaccess in a specific sub-folder

You can place this directive in /blog/.htaccess to deny all files and folders first:

deny from all

Then inside the folders you want to allow access ie blog/css or blog/js , create a .htaccess file with this directive:

allow from all

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM