dtjpnd7517 2014-08-15 20:46
浏览 488

从PHP中的Location Header获取Querystring值

UPDATE

Let's say, my users went to this page:

https://www.abc.com/mypage.php

The response headers for that page are:

    Content-Length  28
    Date    XXXX
    Location    https://abc.com/error.php?target=https%3A%2F%2Fabc.com%2Fmypage.php&
errorReason=Go+To+this+Url
    Server  MochiWeb/1.1 WebMachine/1.10.5 (jokes are better explained)

That means the page is redirecting to https://www.abc.com/errorpage.php with the querystring params in the Location header.

Now on errorpage.php, instead of using $_GET to get the querystring parameters, I wanted to get the Location header, parse out the parameters and print them.

The downside to doing $_GET is, my users can enter any crap in the querystring and my errorpage.php will print it. So i wanted to avoid that by detecting the Location header.

Is there any way to get the Location header from the redirect? I am not seeing using getallheaders() or any other PHP function.

Thanks

  • 写回答

4条回答 默认 最新

  • doufuhao8085 2014-08-15 20:48
    关注

    You can get those URL parameters using the $_GET array:

    $_GET['target'];
    
    $_GET['errorReason'];
    
    评论

报告相同问题?

悬赏问题

  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?
  • ¥50 需求一个up主付费课程