Php – Make php file accessible only from scheduled tasks

cronPHPSecurity

I have several php files that are aimed to run only from scheduled task. I don't want anyone to have access on these files by typing the url into browser or some other way… Is there a way to make this file accessible only for scheduled tasks? I use plesk control panel…

Best Answer

You want to create a .htaccess file with some rules to limit access to those files. This will affect Apache when it goes to serve the files via http, but will not affect the local server and things like running php code for accessing the files.

The Apache documentation has details for Files block here and the deny directive here. Anthonysomerset beat me to an example in his answer.