Changing urls

From: Date: Thu, 08 Mar 2001 05:18:24 +0000
Subject: Changing urls
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-42998@lists.php.net to get a copy of this message
Trying to make a script that gets another and resends it. Begin proxy.php <?php $scriptpath = "http://".getenv(SERVER_NAME).getenv(SCRIPT_NAME); // Log the request $fp = fopen("/www/htdocs/heim/test/heim/test/log.txt", "a"); if ($fp){ fputs($fp, "$REMOTE_ADDR - GET $url\n"); fclose($fp); } if ((substr($url, 0, 7) == "http://") && (substr_count($url, "http://") == 1)){ $pagedata = implode("", file($url)); //try to make absolute links go through the proxy script $pagedata = str_replace("href=\"http://", "href=" $scriptpath "?url="$url, $pagedata); echo $pagedata; } else{ echo "something went wrong"; } ?> The script works great, as long as the line beginning $pagedata is commented out. But, I would like to use that line to convert all absolute links in the page to also go through the proxy.php Also, any ideas of how to process relative links and make them into absolute links? Ex. (lets say $scriptpath is http://www.host.com/proxy.php) <a href="about.html"> which is actually www.abc123.com/about.html Becomes: <a href="http://www.host.com/proxy.php?url=http://www.abc123.com/about.html Any help on converting these links would be very much appreciated _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com

« previous php.general (#42998) next »