title: Getting the URL of browser in PHP after redirection
body: <p>I have a URL for example xyz.com/123456. When I open it up in the browser, the url gets redirected to xyz.com/test_user, where 123456 is user id and test_user is the user name. I want to extract the 2nd URL after it gets redirected from the first. </p>
  
  <p>I have written a script that would get a input of different user ids from a text file and generate the first URL. I want to run the URL, either in the browser or in some way via cmd, and obtain the redirected 2nd URL.
  I have tried using EFFECTIVE_URL in Curl but it keeps returning the 1st URL. I have also tried $_SERVER but it returns the script file rather than the URL.</p>
  
  <p>Is there any way so that I can get the URL entered in the browser window after redirection? 
  Or maybe without even opening the URL in the browser can I get the redirected URL?</p>