2013-02-04 39 views
-3

我正在使用linux和php。我有很多cron任務計劃。我想阻止訪問這些文件,如果有人直接嘗試使用瀏覽器訪問這些文件。我該怎麼做呢。防止在瀏覽器中訪問php文件

回答

1

使用htaccess的將樣品溶液:

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

這不應該說'cronjobs'? – Banath

3
  • 不要將文件放在網站根
  • 需要驗證/授權通過IP地址
+0

認證/授權的建議將是htaccess的。 – CharliePrynn

+0

「需要認證/授權」,那麼cron可以運行它? – 2013-02-04 11:05:07

+1

@Akam - 只要cron通過一組有效憑證。 – Quentin

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>