It is possible to deny access to the directory and allow access to the file with . htaccess? how?

Asked

Viewed 2,633 times

3

I’m trying to make one. htaccess to the user-friendly url’s but would like to make sure that people can’t see my directories and at the same time that the scripts can access the files... it is possible to do this?

1 answer

3


To not list your directories, just use this directive:

Options -Indexes

In the .htaccess or in the directory configuration:

<Directory /www/pasta>
   Options -Indexes
</Directory>

Remember that to use in the .htaccess will depend on the AllowOverride in use allow.

If you want to block access to the files in this directory, it can be more radical and put a . htaccess in the folder with these conditions:

RewriteEngine on 
RewriteRule ^(.*)$ - [F] 

So the path will only serve for includes and similar.

In this case, a simpler path is to put the templates and includes folders outside the site root, for example "next to" the httpdocs, and not inside.

  • It was exactly that, I had seen several "solutions on the web" but nothing that did what I was supposed to do, most of the things returned me error 500, but it worked right :D

Browser other questions tagged

You are not signed in. Login or sign up in order to post.