I have 2 separate servers (Server A and Server B) each with a PHP script (Script 1 and Script 2).
I have PHP script 2 on Server B that I want to run, but only from PHP script 1 on Server A. I do not want any other http requests to pass through the directory on Server B where my protected script resides.
In other words –> run script 2 on Server B only if http request comes from script 1 on Server A. {Note: I do not want to button-down by IP, only by referring script]
Is this doable in an .htaccess file using Allows and Denys? Or is it done some other way.
I can’t do this via a _SERVER var because I can’t seem to capture the referring script in my PHP Script 2.
Thanks.
You can deny access to all IPs except Server A (with the ip = 888.888.888.888) on server B by adding this to the .htaccess in the root of your script:
But it depends how the script on Server B is accessed by Server A – if it’s a server side call it should work.
I would also suggest using a token system:
Server A sends a request and a token to server B (something like md5(a secret string + request data))
Server B checks token and and runs the script if everything checks out.