阻止在浏览器中访问php文件

时间:2013-02-04 11:02:29

标签: php linux

我正在使用linux box和php。我安排了很多cron任务。如果某人直接尝试使用浏览器访问这些文件,我想阻止访问这些文件。我该怎么做。

3 个答案:

答案 0 :(得分:3)

  • 不要将文件放在网络根目录下
  • 需要身份验证/授权
  • 通过IP地址限制访问

答案 1 :(得分:1)

使用 .htaccess 的示例解决方案:

<Files "cronjobs.php">
  Order deny,allow
  Allow from allowedmachine.com
  Allow from localhost
  Deny from all
</Files>

答案 2 :(得分:0)

也许这个? [来源]:https://github.com/h5bp/html5-boilerplate/blob/master/.htaccess

# "-Indexes" will have Apache block users from browsing folders without a
# default document Usually you should leave this activated, because you
# shouldn't allow everybody to surf through every folder on your server (which
# includes rather private places like CMS system folders).
<IfModule mod_autoindex.c>
  Options -Indexes
</IfModule>