php重定向说明
2024-10-07 21:00:21
302 临时重定向
header("location:http://api.com/headline?" . http_build_query($_REQUEST));
301 永久重定向 ( 302 和 301 的区别主要在于搜索引擎,搜索引擎一般不会抓取临时重定向的页面 )
header('HTTP/1.1 301 Moved Permanently');
header("location:http://imcpapi.com/headline?" . http_build_query($_REQUEST));
301 和302 适用于 普通的GET 请求;
如果是 带数据的POST 请求,采用 以上两者都会丢失请求数据,比如:post 请求 a.php
a.php 代码:
header(" Location:b.php ",true,301);
会造成b.php里面获取不到 post的数据
要重定向post请求可以使用 307 ;
header("HTTP/1.1 307 Temporary Redirect");
header("Location: https://api.com/headline?" . http_build_query($_GET));
最新文章
- php : Warning: strftime(): It is not safe to rely on the system's timezone settings.
- GPU渲染和GDI
- PHP操作数据库类
- 分布式系统之CAP理论
- .NET连接SAP系统专题:.NET调用RFC几种方式(一)
- passenger nginx
- JS复习:第二十章
- 利用jink调试程序,时间不准的解决办法
- java_jstl 标签库
- 本地代码上传到git
- 提问:MicrosoftUnderlying input stream returned zero bytes
- Luogu 3793 由乃救爷爷
- and与or的用法
- RIP路由协议(一)
- BZOJ3738 [Ontak2013]Kapitał 【扩展Lucas】
- linux命令分享一:压缩命令
- e645. 处理键盘事件
- Xcode常用插件推荐
- php -- PDO事务处理
- Spring-1-A Post Robot(HDU 5007)解题报告及测试数据