I am trying to know the status of a page whether the page is redirecting to any other domain or staying in the same domain. But this is not working for me.
https://www.rebelmouse.com/rohit/612798926.html
when i open this url it redirects me to other domain and i want to detect whether it stays on rebelmouse.com or opens any other domain.
I have tried curl_init() to know the status but it gives 200 it does not provide specific http code to identify redirection.
CODE:
function file_get_contents_curl($url) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7");
curl_setopt($ch, CURLOPT_AUTOREFERER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
$data = curl_exec($ch);
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$urlInfo = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
curl_close($ch);
echo $urlInfo;
return $data;
}