PHP fopen 会遵循 301 重定向吗?
我们有一段遗留代码(ab)使用 fopen()
通过 HTTP 调用资源:
@fopen('http://example.com')
我们希望将 example.com 移动到另一个主机,然后发送“301 Permanently Moved”,但是,我们不完全确定 @fopen()
是否会遵循这一点。
初步测试表明事实并非如此。但也许我错过了一些配置部分。
We have a piece of legacy code that (ab)uses fopen()
calls to resources over HTTP:
@fopen('http://example.com')
We want to move example.com to another host and then send "301 Permanently Moved", however, we are not entirely sure if @fopen()
will follow this.
Initial tests show me that it does not. But maybe I miss some configuration piece.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
从版本 5.1.0 开始,有 max_redirects 选项,这使得fopen HTTP 包装器遵循
Location
重定向:您可能需要明确设置它,以防您的配置禁用此功能。从文档修改的示例:
Since version 5.1.0, there's the max_redirects option, which makes the fopen HTTP wrapper follow the
Location
redirect:You might want to set it explicitly, in case your config disables this. An example modified from the docs: