Get redirected URL from URL [duplicate]

一曲冷凌霜 提交于 2019-12-06 11:59:06

Make your request using curl with curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); which will cause curl to follow the redirect.

Then, you can use curl_getinfo($ch, CURLINFO_EFFECTIVE_URL); which will give you the last effective URL that curl fetched.

Alternatively, you can set CURLOPT_FOLLOWLOCATION to false, and set CURLOPT_HEADERS to true, and parse the redirect location out yourself using a simple regex.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!