I'm trying to create a real simple proxy server and this is what I have sofar:
$url = $_GET['url'];
$page = file_get_contents($url);
$page = str_replace("<a href='", "<a href='http://www.myurl.com/?url=", $page);
$page = str_replace("<a href='/", "<a href='".$url."/", $page);
$page = str_replace('<a href="', '<a href="http://www.myurl.com/?url=', $page);
$page = str_replace('<a href="/', '<a href="'.$url.'/', $page);
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
echo $page;
How can I go through $page and replace all the links with http://www.myurl.com/?url=$thelink ?
So when the page comes up I can just click the link and it will just send that to my proxy server?
What I have works great as long as the links either start with [url]http://,[/url] www, or /. But if its a local page this won't work.