问题原文
原帖链接 · ACristian24 · CC BY-SA 3.0
Could someone help me with making a .htaccess file or how can i limit access to specific locations.
All my user accessible files are located in /var/www/website however I also have some more folders like /var/www/website/secrets, var/www/website/tools that I want them inaccessible from a web browser.
My main issue is that I have cronjobs executing php scripts from var/www/website/tools and I do not want to deny them access also.
已采纳解答
原帖链接 · Adam V · CC BY-SA 3.0
To block all web access to those directories, in each one just drop an .htaccess file with the following line:
Apache 2.4.x:
Require all deniedApache 2.2.x:
Order deny,allow Deny from all
This all of course assumes that you have AllowOverride configured such that .htaccess files can be used. If not, then you can place those lines in the virtualhost entry in the global configuration wrapped in something like this:
<Directory "/var/www/website/secrets">
...whichever entry from above here....
</Directory>
Also, so long as your crons are invoking the scripts directly (with the PHP binary) and aren't doing silly things like curl's or wget's back to itself, then those .htaccess entries will have no affect on them since it only affects web-based traffic (things coming through Apache).
I would also recommend giving the Apache documentation on this subject matter a read - it really is quite informative and helpful:
- https://httpd.apache.org/docs/2.4/howto/access.html
- https://httpd.apache.org/docs/2.4/howto/auth.html
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
