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...
|
feedback
|
|
You want to create a The Apache documentation has details for Files block here and the deny directive here. Anthonysomerset beat me to an example in his answer. | |||
|
feedback
|
|
If your scheduled task uses the command line php then you could use htaccess to disallow access to the directory that your php file is in (or the php file itself). A htaccess block will look similar to this:
Just drop this into an .htaccess file in the directory with your php file. | ||||
feedback
|
|
You can simply place the file(s) in question outside of the DocRoot (e.g. in
As a last-ditch option, or if you need to access the script from multiple locations or locations with changing IP addresses, consider using a shared secret, via code like:
Then when you call the script, only you know the right parameter to tack onto the end (http://somehost.com/somescript.php?secretpass=hmAPcrkqjDhMkJw). *: Unless you explicitly set up a separate script or a symlink to do so, of course, but now we're just being pedantic. | |||
|
feedback
|