title: PHP's file_get_contents: dealing with relative paths inside the result
body: <p>I'm trying to solve a cross-domain issue, so I'm implementing a script that will get a URL from a GET parameter and open with file_get_contents. It works fine until the page try to get relative paths like (the following line is inside index.html):</p>
  
  <pre><code>&lt;script src="js/custom_script.js" /&gt;
  </code></pre>
  
  <p>If I create a regex with preg_replace that replace all the HTML data switching js/custom.js to <a href="http://content.domain/js/custom_script.js" rel="nofollow">http://content.domain/js/custom_script.js</a> it also works, but the problem is that I don't always know how many levels are inside the page I'm trying to open, like: index.html could have a button to another page with another relative paths.</p>
  
  <p>Is there an elegant solution to this problem?</p>