swamp Posted May 21, 2008 Share Posted May 21, 2008 Hi there, I have a page which is reading news off a website using php. How can you setup a page so that all links go external? EG: <a href="../main_sections/news_archive/artciles/502.htm"> Read more . . .</a> Go to "http://www.otherwebsite.com/main_sections/news_archive/artciles/502.htm" Instead of "http://www.mywebsite.com/main_sections/news_archive/artciles/502.htm" I would rather not have to change the page on "otherwebsite" but simply add some php to the page on "mywebsite" to make all links from that page go to www.otherwebsite.com/ By the way, all the links from this page are meant to go to the otherwebsite. Thanks, swamp Link to comment https://forums.phpfreaks.com/topic/106609-all-links-forwarding-to-external-site/ Share on other sites More sharing options...
littledragon Posted May 21, 2008 Share Posted May 21, 2008 if all the links start with .../, then you need str_replace $str = '<a href="../main_sections/news_archive/artciles/502.htm"> Read more . . .</a>'; $str = str_replace('href="../', 'href="http://othersite.com/', $str); echo $str; Link to comment https://forums.phpfreaks.com/topic/106609-all-links-forwarding-to-external-site/#findComment-546403 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.