请求重定向,即使CURLOPT_FOLLOWLOCATION设置为FALSE

I'm new to PHP. I have searched StackOverflow and followed instructions from answers to similar questions. However, the instructions are not working for me.

This is the issue:

I'm trying to fetch HTML using PHP cURL for parsing. http://actas.rfef.es/actas/NPortada This is a publicly-accessible page. When I request the page through a browser's address bar, it works fine. However, if the request is through cURL, I'm redirected to http://actas.rfef.es/actas/NLogin (0 byte blank page). I thought useragent may be an issue and set curl's user agent value and followlocation to false,but still it redirects!

Here is my code:

$home="http://actas.rfef.es/actas/NPortada";
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$home);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_HEADER, TRUE);
curl_setopt($ch,CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; rv:18.0)Gecko/20100101 Firefox/18.0");
curl_setopt($ch,CURLOPT_FOLLOWLOCATION, FALSE);
curl_setopt($ch,CURLOPT_COOKIEJAR, "cookies.txt");
echo curl_exec($ch);
curl_close($ch);

Why does it redirect, even though followLocation is set to false? There are no meta refresh tags in that target page.

How can I avoid being redirected and get the html of the targeted page? What am I doing wrong?

I've been struggling with this problem for the last 3 days. Please will anyone help me with this? Thanks in advance.

browser OK! but curl ( on php ) does not work! then see the below

Always, check curl option on command line! beacuse it's so easy!

  1. curl < url to visit >

  2. see the request header on browser's deveopment tool!

and...

  1. curl with browser's request header

    curl < url to visit > with

    -A "User-Agent" or

    -e "Referer" or

    --cookie "Cookie Key:value"

    etc...

In your case,

http://actas.rfef.es/actas/NPortada working good on browser, but not work on curl

you can see the redirection by using curl -v http://actas.rfef.es/actas/NPortada

and see the browser and using development tool.... then no redirection founded!

enter image description here

and re-try curl with a browser's request header! User-Agent not working, Referer not working too.

then try with cookie option!

curl -v --cookie "JSESSIONID=B2F73A51E07D624FB205A114B2CC5D19" "http://actas.rfef.es/actas/NPortada"

I found the solution. http://actas.rfef.es/actas/NPortada must be requested with cookie!