Forum Moderators: coopster

Message Too Old, No Replies

Converting Relative URL to Absolute (Need Help)

         

drpip

9:08 pm on Jul 27, 2004 (gmt 0)

10+ Year Member



I have read the post of "andreasfriedrich" titled "Resolving a relative URI" in this thread:

[webmasterworld.com...]

Unfortunately, I could not figure out how to use it.

My case is simple. I have a PHP file named "fetch.php" that fetches a HTML page from my other website. In this file, I only have 1 line of code:

<?php
include("http://myothersite.com/index.html");
?>

Can someone please tell me what code should I add to fetch.php so that it displays [myothersite.com...] in absolute URL?

I really need help on this. I have gone through many forums for the past 20 hours (a little dizzy and very tired). Please help!

drpip

9:09 pm on Jul 27, 2004 (gmt 0)

10+ Year Member



Sorry, when I say displays [myothersite.com...] in absolute URL, I meant display the LINKS in [myothersite.com...] in absolute URL.

Warboss Alex

3:16 pm on Jul 28, 2004 (gmt 0)

10+ Year Member



You'd have to fetch the contents of your other site into an output buffer, and then do a preg_replace on the buffer's contents so that the links are converted properly.

//fetch.php
<?php

ob_start();

include (file/from/other/site);

$out = ob_get_contents();

ob_end_clean();

//do your replacing of links here

print $out; //display the web page with changed links

?>

drpip

7:19 pm on Jul 28, 2004 (gmt 0)

10+ Year Member



Warboss Alex,

Thanks for your response. Can you tell me how to integrate your suggestion with andreasfriedrich's make_abs function?