0

I got stuck at the point:

The php script makes curl request to another php script on external ip, like

$ip = "111.222.333.444";
curl_setopt($ch, CURLOPT_URL, $this->ip . "/index.php");

I cannot modify the first script and unfortunately external ip is down forever.

So, I need to route all requests to the new same script on my server, but cannot understand how to do it better.

If there is domain name instead of ip, I can change hosts file. But it's not that case.

I googled about iptables, but how can I connect requests to exact script on my server? What changes do I need to do there?

losusovic
  • 608
  • 5
  • 22
Maksim
  • 17
  • 1
  • 7

1 Answers1

0

if this is all happening on your local machine you can use iptables to redirect. This is not an optimal solution as iptables over time can do things you you aren't expecting anylonger and you may forget that iptables are affecting traffic.

However if you have access to the server on the server where script B resides, you can use a server redirect.

For instance if you are running Apache you can drop a RewriteRule in an htaccess file that resides in the same dir as script B that simply looks for any request to assets in the dir, or a specific request depending on need, and redirect to resource C

RewriteEngine on RewriteRule (.*) http://www.newdomain.com/ [R=301,L]

roberthuttinger
  • 1,172
  • 1
  • 17
  • 31