How can I visit URL in my web page backend and get this URL after visited [closed]

User get a URL from me . before they get I want to run this URL in my webpage backend. after run I want to get the exact URL . I do this because first URL is redirected I want to get the redirected URL