title: Get final redirect with Curl PHP
body: <p>I have to get the final redirect url from the this: <a href="https://web.archive.org/web/20070701005218/http://www.maladnews.com/" rel="nofollow">https://web.archive.org/web/20070701005218/http://www.maladnews.com/</a> which actually redirects to this: <a href="https://web.archive.org/web/20080109064420/http://www.maladnews.com/Site%203/Malad%20City%20&amp;%20Oneida%20County%20News/Malad%20City%20&amp;%20Oneida%20County%20News.html" rel="nofollow">https://web.archive.org/web/20080109064420/http://www.maladnews.com/Site%203/Malad%20City%20&amp;%20Oneida%20County%20News/Malad%20City%20&amp;%20Oneida%20County%20News.html</a></p>
  
  <p>I tried the answers from other stackoverflow answers which works for other websites but not for the above link.</p>
  
  <p>I've tried to extract regular location header:</p>
  
  <pre><code>if(preg_match('#Location: (.*)#', $html, $m))
   $l = trim($m[1]);
  </code></pre>
  
  <p>and also checked the javascript way:</p>
  
  <pre><code>preg_match("/window\.location\.replace\('(.*?)'\)/", $html, $m) ? $m[1] : null;
  </code></pre>
  
  <p>Please help!</p>