Reputation: 741
I am trying to proxy this request to my server:
http://10.0.1.26/port_3480/data_request?id=status&output_format=json&DeviceNum=79
using a simple PHP proxy that I found:
<?php
$url = $_REQUEST['url'];
if (preg_match('/\b(https?|ftp):\/\/*/', $url) !== 1) die;
echo (file_get_contents($url));
?>
but the variable arguments are not passed...
how do I modify the PHP script in order to get the arguments from the url, which I pass to the proxy like this:
http://10.0.1.15/proxy.php?url=http://10.0.1.26/port_3480/data_request?id=status&output_format=json&DeviceNum=79
Upvotes: 0
Views: 348
Reputation: 42695
You simply need to ensure that the URL is encoded before it's used as a parameter in another URL. You should be fetching this URL instead:
http://10.0.1.15/proxy.php?url=http%3A%2F%2F10.0.1.26%2Fport_3480%2Fdata_request%3Fid%3Dstatus%26output_format%3Djson%26DeviceNum%3D79
Upvotes: 2