Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9144929
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:23:20+00:00 2026-06-17T10:23:20+00:00

I did a search on the site before asking this question, but I believe

  • 0

I did a search on the site before asking this question, but I believe this hasn’t been asked before; apologies if it already has been and I missed on finding it.

What I’m trying to achieve is a little ‘weird’, I guess?

So, say for example, I’m POST’ing (or GET’ing from) data to a page that returns the response along with a ‘Location’ in the header that I want it to follow. Under most circumstances, this would be no problem as I could just grab the ‘Location’ value from the headers, then follow it.

However, consider this scenario:
The website/page I’m getting data from is sending me a Location header, and the resulting redirect has yet another ‘Location’ header. This is random, some redirects will give me the expected file after 2 redirects, others after 4, or so.

I absolutely need to record the most recent (last) ‘Location’ value that was sent to me. How do I do that? I currently have PHP Curl’s Follow Location set to ‘on’ so it automatically follows any/all locations without me intervening. Since it does this, how do I grab the value of the last location it followed?

Example, I post data to Website A using php curl. The reply from Website A contains a ‘Location’ redirect to Website B. PHP Curl follows it. Website B has a ‘Location’ redirect, yet again, to Website C. PHP Curl automatically follows it. Website C then has a ‘Location’ redirect to Website D. PHP Curl automatically follows it, as it did before. Website D, then, sends me the actual file I wanted to download.

Since PHP Curl is automatically following the ‘Location’, how do I grab the last Location value? In the example above, how would I grab the ‘Location’ value in Website C, which was the last one followed before reaching Website D, the end destination?

Apologies if I haven’t been clear enough, I’ve tried my best to explain what I want to do; it’s just the situation is a bit tricky to put into words.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T10:23:22+00:00Added an answer on June 17, 2026 at 10:23 am

    Do you look for something like this?

    $last_url = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
    

    you can find the documentation on curl_getinfo() here http://www.php.net/manual/en/function.curl-getinfo.php

    As I read your question a second time my answer is probably not the final solution, but you could get the HTTP Header information from the last location and grab the HTTP_REFERER . I don’t have an example for this but this could be a way you will get the information you need.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I did a search around and couldn't find this already asked but I'm sure
Please note that this is not homework and i did search before starting this
I did a search before asking so please don't tell me to do that.
I did a lot search already but couldn't find a straight anwser. I have
I tried this question before and did not supply enough information, so here are
First, let me apologize if this is a repeat question. I did a search
I did do some googling and searching on this site but did not find
I did a search through the site, but it's still not working. var blah2
I did search the forum and did not find a similar question. I'm looking
I did a search on the elements of the list, but the problem is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.