在包含的页面上使用file_get_contents和更改链接域?

On my page I have this piece of code:

<?php
$homepage = file_get_contents('http://www.nbc.com/');
echo $homepage;
?>

It includes the NBC website perfectly, but I notice that all of the links on the NBC.com website start with my domain name instead of http://nbc.com so they don't work.

So for example instead of http://nbc.com/the-blacklist/episodes being displayed on http://nbc.com website, its displaying http://my-domain.com/the-blacklist/episodes.

Is there any way to use file_get_contents do include a page into my URL, but make sure all the links on the page are the original links so they work fine?

The links inside of pages you are pulling are using relative links (/page.html) instead of the full URL, you will need to do a Regex on the variable or string replace. To test it out you could do the following:

$domain = 'http://www.nbc.com';
$pull = file_get_contents($domain);
echo str_replace('href="/', 'href="' . $domain . '/', $pull);