header 跳转时报错误。Header may not contain more than a single header, new line detected
我在用php的header做跳转时,报错误。
Header may not contain more than a single header, new line detected
先贴一下代码:
class advertJumpUrl
{
/**
* 广告唯一的key
* @return array
*/
private static function aGetKey()
{
$sKey = Ko_Tool_Input::VClean("r","k",Ko_Tool_Input::T_STR);
$sKey = \apps\brand\cpm\MFacade_LogApi::sDecrypt($sKey);
$aPara = explode('_', $sKey);
return $aPara;
} /**
* 广告跳转的url
* @return url
*/
private static function sGetUrl()
{
$sUrl = Ko_Tool_Input::VClean("r","t",Ko_Tool_Input::T_STR);
return \apps\brand\cpm\MFacade_LogApi::sDecrypt($sUrl);
} /**
* 程序执行
*/
public static function vRun()
{
$aPara = self::aGetKey();
$sUrl = self::sGetUrl();
// $sUrl = rawurldecode($sUrl);
if($aPara && $sUrl) {
// 记录点击事件
\apps\brand\cpm\MFacade_LogApi::vClick($aPara[], $aPara[]);
header('HTTP/1.1 301 Moved Permanently');
header('location:'.$sUrl);
exit;
}
header('HTTP/1.1 301 Moved Permanently');
header('location:/');
exit;
}
}
advertJumpUrl::vRun();
在网上搜索一下,是因为URL编码有问题。我尝试用urlencode 然后再urldecode。发现不行。
有人建议用rawurlencode。我试了试,成功了。
urlencode 和rawurlencode 的区别:
urlencode 将空格则编码为加号(+)
rawurlencode 将空格则编码为加号(%20)
参考文档:
https://stackoverflow.com/questions/16320403/getting-warning-header-may-not-contain-more-than-a-single-header-new-line-dete
http://www.jb51.net/article/24123.htm
header 跳转时报错误。Header may not contain more than a single header, new line detected的更多相关文章
- 关于header跳转之后的乱码问题
关于header跳转之后的乱码问题 http://www.360doc.com/content/11/0603/19/7052474_121495648.shtml 问题:不同网站的跳转出现乱码,不同 ...
- location跳转和header跳转的区别
1:header("location:url") 跳转之前不能有任何输出,如果想在header之前有输出,则要修改php.ini文件.具体 output_handler =mb_o ...
- net::ERR_CONNCTION_ABORTED与http post request header is too large 错误
开始浏览器报(net::ERR_CONNCTION_ABORTED)然后就一直找这个错误是怎么引起的,找了一圈也没有找到答案. 后来看了一下后台发出后台错http post request heade ...
- maven 错误:读取 xxx.jar 时出错;invalid LOC header (bad signature) 1 错误
reqHeader:{Accept=text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8, Upgrade-Insecure- ...
- Ubuntu 16.04错误:正在读取软件包列表... 有错误! E: Encountered a section with no Package: header E: Problem with MergeList /var/lib/apt/lists/ppa.launchpad.net_t-tujikawa_ppa_ubuntu_dists_xenial_main_i18n_Translatio
错误: 正在读取软件包列表... 有错误! E: Encountered a section with no Package: header E: Problem with MergeList /va ...
- AIX上增加逻辑卷时报错误0516-787 extendlv: Maximum allocation for logical volume
AIX上增加逻辑卷时报错误0516-787 extendlv: Maximum allocation for logical volume jdelv02 is 512. 在往aix使用chfs -a ...
- JSP中,当页面为404或者500时。设置跳转到错误提示页面
最好的就是在WEB.XML文件中配置错误代码的跳转页面,首先建立个 出现500错误的页面,提示出错了,然后再WEB.XML文件中配置,配置如下 一. 通过错误码来配置error-page <er ...
- 跳过复制错误——sql_slave_skip_counter
昨天不少同学讨论<小心,前方有雷 —— sql_slave_skip_counter>,有说作者在玩文字游戏,扯了那么多sql_slave_skip_counter=1不还是跳过一个事务嘛 ...
- mysql主从复制跳过复制错误【转】
跳过复制错误 mysql因为binlog机制问题,有些时候会出现从库重放sql执行失败的情况,特别是旧的STATEMENT模式最容易出现这种情况(因为函数和存储过程等原因),这也是为什么强调使用mix ...
随机推荐
- eclipse发布后在tomcat下没有文件夹,服务器的Server locations不能修改
主要是因为Server locations中的deploy路径不正确,要修改这个路径,需要移除服务器中的所有项目,然后点击清空,这时再双击服务器,既可修改这个设置.
- net core体系-web应用程序-4net core2.0大白话带你入门-4asp.net core配置项目访问地址
asp.net core配置访问地址 .net core web程序,默认使用kestrel作为web服务器. 配置Kestrel Urls有四种方式,我这里只介绍一种.其它方式可自行百度. 在Pr ...
- python--json、jsonpath
1.遇到一个问题:android返回的基本都是标准的json格式,当我们想要对层层嵌套的json中找到自己想要的字段并进行校验时 难道需要一层一层的解析?? 2.使用jsonpath list_3={ ...
- 51Nod1336 RMQ逆问题 其他
原文链接https://www.cnblogs.com/zhouzhendong/p/51Nod1336.html 题目传送门 - 51Nod1336 题意 题解 我们将输入的一个区间的答案称为 V ...
- Codeforces 986D Perfect Encoding FFT 分治 高精度
原文链接https://www.cnblogs.com/zhouzhendong/p/9161557.html 题目传送门 - Codeforces 986D 题意 给定一个数 $n(n\leq 10 ...
- python josn包
Python josn包中的编码与解码方法 对于Python数据类型进行编码解码 json.dumps 对python的数据类型进行json格式编码 :(将dict转为json格式) eg: imp ...
- M. Subsequence 南昌邀请赛
链接: https://nanti.jisuanke.com/t/38232 先给出一个s母串 然后给出n个子串 判断是否为母串的子序列 3000ms 2993ms过的.... 蒻鲫的代码: 建立表 ...
- spring mvc中的service和controller中读取不到properties值
根据web.xml读取配置文件中的顺序来看 controller层和service层来自于spring mvc.xml中读取,所以必须要在spring mvc.xml中配置读取资源文件夹方式
- python3解析库lxml
阅读目录 1.python库lxml的安装 2.XPath常用规则 (1)读取文本解析节点 (2)读取HTML文件进行解析 (3)获取所有节点 (4)获取子节点 (5)获取父节点 (6)属性匹配 (7 ...
- Codeforces 208A-Dubstep(字符串)
Vasya works as a DJ in the best Berland nightclub, and he often uses dubstep music in his performanc ...