Give no one access in a directory .htaccess

2019-06-26 07:21发布

问题:

It is probably very simple but I can't find it. I want to make a .htaccess file so no one can get into the folder. except for the php on the server.

does anyone know the code line?

Thanks Matthy

回答1:

You want

Deny from all


回答2:

Instead of denying all traffic you could try redirecting it with mod_rewrite to make it useful i.e. back into the flow of the site.

RewriteEngine on
rewriteRule ^path/to/forbidden/directory/? index.php [L]


回答3:

Maybe it's better to change the rights and ownerships of the folder instead of using .htaccess to do it.

Deny from All

is the way to do it in .htaccess



回答4:

<Files *.*>
order allow,deny
deny from all
</Files>