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 ...
随机推荐
- 【Android】setHapticFeedbackEnabled 设置
使其在触摸的时候没有触感反馈.接着设置长按事件的监听. 代码在:launcher launcher->setupViews方法 // Setup the workspacemWorkspace. ...
- rem布局js设置,设置网页文档参考字体闭包函数
(function (doc, win) { var docEl = doc.documentElement, resizeEvt = 'orientationchange' in window ? ...
- arcgis 10 File GDB转成9.3 File GDB
背景:已有的File GDB数据是在ArcGIS 10下面创建的,在运行9.3的电脑上无法读取,需要转换成低版本. 方法: 1.在ArcGIS Toolbox中找到相关工具(datamanagemen ...
- bat处理快速安装jdk脚本
- day8.登陆注册简单实现
username = input('请输入注册的用户名:') password = input('请输入注册名的密码:') with open('list_of_info',mode='w',enco ...
- 使用link rel="shortcut icon"为网页标题加图标
<title>会员卡券</title> <link rel="shortcut icon" href="http://GT/img/favi ...
- BZOJ1396 识别子串 字符串 SAM 线段树
原文链接http://www.cnblogs.com/zhouzhendong/p/9004467.html 题目传送门 - BZOJ1396 题意 给定一个字符串$s$,$|s|\leq 10^5$ ...
- js清除单选框所选的值
js清除单选框所选的值 $("input[type='radio']").removeAttr('checked');
- Codefoces Gym 101652 【最大连续和】
<题目链接> 题目大意: 给你一段只由 'B'和'R'组成的字符串,问你在连续的区间内,"B"和"R"的差值最大是多少,输出该区间:如果对于差值相等 ...
- Intellij IDEA 解决 Maven 依赖下载慢的问题
最近用 IDEA 导入 Hadoop 源码, 但下载依赖特别慢.导致经常需要重启 IDEA 并且下载的过程非常艰难, 网上找了一些方法,各种尝试,终于解决了这个问题.本篇文章总结最关键的两点,希望能帮 ...