简体   繁体   English

如何使用PHP获取重定向的页面网址

[英]How to get redirected page url using PHP

I am using file_get_contents() function to get a page source. 我正在使用file_get_contents()函数来获取页面源。 When I am trying to get the source of http://example.com , which is internally redirected to http://example-new.com . 当我尝试获取http://example.com的源时,该源在内部重定向到http://example-new.com Here I am getting the source of second URL. 在这里,我得到第二个URL的来源。 Is there any solutions to get second URL to identify to which URL it is redirected to. 是否有解决方案来获取第二个URL,以标识第二个URL重定向到哪个URL。

Just make request, wait for 200 and check url. 只需提出请求,等待200并检查url。 I would recommend reading about curl. 我建议阅读有关卷曲的文章。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM