donglian1953 2013-05-16 07:15
浏览 212
已采纳

使用CURLOPT_FOLLOWLOCATION设置为true将日志卷曲重定向

I have an script that grabs content from third party sites and if the url is not found the site redirects with a 302 header location to a custom not found webpage instead of sending a 404 not found. The script also caches the content returned by curl_exec but i don't want to cache the error pages, so is there a way to log those redirects if i have turned on CURLOPT_FOLLOWLOCATION? How can i solve this situation? I know i could just find the error message using a dom parser and if found just discard it, but i want to know if there is other ways to accomplish this.

  • 写回答

3条回答

  • dpoxk64080 2013-05-17 12:50
    关注

    I ended up disabling followlocation so i just have to catch the 302 code and if it's present i don't cache the page. Thought there would be a way of catching all codes before curl redirects.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥30 vmware exsi重置后登不上
  • ¥15 易盾点选的cb参数怎么解啊
  • ¥15 MATLAB运行显示错误,如何解决?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题
  • ¥20 yolov5自定义Prune报错,如何解决?
  • ¥15 电磁场的matlab仿真
  • ¥15 mars2d在vue3中的引入问题
  • ¥50 h5唤醒支付宝并跳转至向小荷包转账界面