简体   繁体   中英

How can I stop direct access of a folder with Apache using .htaccess?

I have tried to use

deny from all

So it blocks the whole contains and can be access by the page also..

Just create a blank index.html file and upload it to each folder. It's easier and safer..

You can use the following code to deny access to the folder:

RedirectMatch 403 ^/folder/?$

just replace folder with name of the folder you want to deny access to.

To deny access to folder and files

You can use :

RedirectMatch 403 ^/folder/.+$

This will show forbidden error for the folder and files.

Deny from all

Allow from all

This code is working under .htaccess to solve the above problem

Thanks guys for help...

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