Created
December 30, 2016 13:04
-
-
Save hasnhasan/78857a3751a4201f39475dc1076d70d3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function isLocation($url,$returnBaseUrl= false){ | |
$ch = curl_init($url); | |
curl_setopt($ch, CURLOPT_NOBODY, 1); | |
curl_setopt($ch, CURLOPT_HEADER, 0); | |
curl_setopt($ch, CURLOPT_MAXREDIRS, 3); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0); | |
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); | |
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); | |
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT ,5); | |
curl_setopt($ch,CURLOPT_TIMEOUT, 15); | |
curl_exec($ch); | |
$redirectUrl = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL); | |
curl_close($ch); | |
if (($redirectUrl == $url) && !$returnBaseUrl) { | |
return false; | |
} | |
return $redirectUrl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment