<html>
<head><title>404 Not Found</title></head>
<body bgcolor="white">
<center><h1>404 Not Found</h1></center>
<hr><center>nginx/1.12.2</center>
</body>
</html>
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!--用于禁用MSIE和Chrome友好错误页的填充 -->
异常说明
- 使用wangEditor编辑器,提交内容;
- 正常数据的文本,正常提交;
- 外网使用时,上传图片或视频后,出现404页面,具体提示信息:
a padding to disable MSIE and Chrome friendly error page
; - 内网使用时,正常;
异常排查
- 把所有精力放在解决“a padding to disable MSIE and Chrome friendly error page”是个错误,导致对NGINX的配置、内网外网都进行过怀疑和调试;
- 尤其是内网可用,外网不可用,更是导致跑了很多远路;
- 其实,问题的关键在于上传图片后,
正常的路由无法获取,就代表网络层被阻断了
。 - 逐行调试,对代码转义后,一切正常。
解决方案
转义函数
/*HTML代码转义*/
function escapeHtml(unsafe) {return unsafe.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
}
字段调用
$.ajax({type: "post",url: "?m=Forum&a=forumDeal&act=add",async: true,data: {section: $('#sect_name').val(),forum_title: $('#forum_title').val(),forum_abstract: $('#forum_abstract').val(),forum_age: $('#forum_age').val(),forum_sex: $('#forum_sex').val(),forum_chief: $('#forum_chief').val(),forum_subjective: escapeHtml(forum_subjective),forum_objective: escapeHtml(forum_objective),forum_assess: escapeHtml(forum_assess),forum_treat: escapeHtml(forum_treat),forum_effect: $('#forum_effect').val(),forum_evaluate: escapeHtml(forum_evaluate)},dataType: "json",success: function (res) {//console.log(res);if (res.code == 0) {layer.msg(res.msg, {icon: 2, time: 2000});} else {layer.msg(res.msg, {icon: 1, time: 2000}, function () {window.parent.location.href = "?m=My&a=myForum";});}}, error: function (err) {console.log(err)}});
入库转义
$forum_age = html_entity_decode($_POST['forum_age']);$forum_sex = html_entity_decode($_POST['forum_sex']);$forum_subjective = html_entity_decode($_POST['forum_subjective']);$forum_chief = html_entity_decode($_POST['forum_chief']);$forum_objective = html_entity_decode($_POST['forum_objective']);$forum_assess = html_entity_decode($_POST['forum_assess']);$forum_treat = html_entity_decode($_POST['forum_treat']);$forum_effect = html_entity_decode($_POST['forum_effect']);$forum_evaluate = html_entity_decode($_POST['forum_evaluate']);
@漏刻有时