Restrict access to web directory with .htaccess
.htaccess files are extremely useful in many cases for users who either do not have root permissions or for users who simply aren't comfortable in making changes in their web server's configuration file. Trying to debug .htaccess not working isn't always the easiest thing to do, however, hopefully by checking the discuss below mentioned about security, htaccess, , , .htaccess common problems as well as the troubleshooting tips, you'll have a better grasp on what you may have to modify to get your .htaccess file running smoothly.Problem :Let me just say that doing this sort of thing with .htaccess files has never been a strong point for me. Let's say that I have a directory in my web root: /dir/data
Within that directory let's say that I have a file called data.txt
I need to completely restrict access to data.txt (or the whole data directory). The only things that I want to be able to access the data.txt is a script located at /dir/data.php
I also use scp in a shell file on another server to update the data.txt file, hence this shell file will have to be allowed to access the directory and file as well. I for the life of me can't seem to find what I need on Google (though I know it's there somewhere). I really appreciate any help.
You could deny all text file access...
<Files *.txt>
Order deny,allow
Deny from All
</Files>
Another option, perhaps preferred, is to move that directory (or just the file) outside of your web root. That way its impossible to get to it via web browser but it is still available to your scripts.
Comments
Post a Comment