douju6542 2010-11-29 00:11
浏览 32
已采纳

php curl关注重定向?

I have a page that is meant to receive a curl request from another server.

I need to format this curl request to another format.

so I have this code

<?php
$id =     (isset($_GET['msgid'])    ? $_GET['msgid']   : 'null');
$from =   (isset($_GET['from'])     ? $_GET['from']    : 'null');
$body =   (isset($_GET['content'])  ? $_GET['content'] : 'null');
$status = (isset($_GET['status'])   ? $_GET['status']  : 'null');

header("location: ../action/receive_message/$id/$from/$body/$status");
?>

so, if someone was to launch a curl request to
http://example.com/intercept/test.php?id=123&from=me&body=something;

Will that call
http://example.com/action/123/me/something/null?

Or if not is there a way i can get it to?

The other one is.

Is there a way I can do this in .htaccess? So I dont have to create a seperate file for this?

  • 写回答

2条回答 默认 最新

  • dqe9657 2010-11-29 00:53
    关注

    Curl doesn't follow redirects by default.

    If you're running curl from the command line, you need to add the -L flag to your command to make it follow redirects.

    If you're calling curl via a library, you need to set the FOLLOWLOCATION curl option to true (or 1), and the exact code to do that will depend on the language/library/wrapper you're using.

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

报告相同问题?

悬赏问题

  • ¥20 sim800c模块 at指令及平台
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题