微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

PHP / Apache错误:406不可接受

所以今天我收到这个错误,我把它缩小到这个问题:

我的网站是我的音乐家页面。 它允许人们进来看我的照片,新闻,我的音乐和我正在玩的事件。

一切都在膨胀,我手动input数据到MysqL,让它自动喂养主页。 现在我添加控制面板,以便从networking添加,编辑和删除数据库中的内容

一切工作正常,除了添加/编辑事件的能力。 我已经缩小到事实,我不能input2个url或我得到这个错误。 我需要input2个url(一个查看活动页面一个购买门票),但我不能input超过1,有什么我可以做的纠正或解决这个错误无论是在Apache或我码?

国防部重写目录如果文件/文件夹找不到

jQuery.get没有收到服务器上的最新版本的文件

Apache服务器中的全局variables

“裸”git存储库:我怎样才能让Apache总是“看到”最新的提交?

.htaccess追加https:// www

<?PHP $specevlink = "http://facebooklink.com"; $specgigtick = "http://ticketplacelink.com"; ?> <form method="post" action="index.PHP?page=editgigs"> <table> <tr> <td> Event Page (Link): </td> <td text-align: left;"> <input type="url" name="giglink" value="<?PHP echo $specevlink; ?>" /> </td> </tr> <tr> <td> Event Tickets (Link): </td> <td text-align: left;"> <input type="url" name="gigtick" value="<?PHP echo $specgigtick; ?>" /> </td> </tr> </table><br /> <input type="submit" name="editgig" value="submit" /><br /> <br /> </form>

编辑:

添加了完整的代码行,所以你可以看到我正在使用的是什么,

这里是第1步的图片这是第2步的图片

这包含在一个index.PHP文件中:

<?PHP if(isset($_GET["page"])){ $page = $_GET["page"]; } else { $page = ""; } if($page === "editgigs"){ include ('inc/logincheck.PHP'); ?> <div class="label"> EDIT GIGS </div><br /> <div margin: 0 auto; text-align: center; width: 100%"> <form method="post" action="index.PHP?page=editgigs"> <?PHP if(!isset($_POST['selectgigs'])){ if(!isset($_POST['updgigs'])){ ?> Select one of the options below:<br /> <br /> <select name="selgigs" max-width: 26%;"> <?PHP while($gigsall_data = MysqLi_fetch_array($gigsall_query)){ $gigid = stripslashes($gigsall_data['idgigs']); $gigdate = stripslashes($gigsall_data['date']); $gigname = stripslashes($gigsall_data['name']); $gigdate = date('F j,Y',strtotime($gigdate)); ?> <option value="<?PHP echo $gigid; ?>"> <?PHP echo $gigdate; ?>: <?PHP echo $gigname; ?> </option> <?PHP } ?> </select><br /><br /> <input type="submit" name="selectgigs" value="Select" /><br /> <br /> <?PHP } } if(isset($_POST['selectgigs'])){ $gigtoed = trim($_POST['selgigs']); $specgig_query = MysqLi_query($con,"SELECT * FROM `gigs` WHERE `idgigs` = '$gigtoed'") or die(MysqLi_error($con)); $specgig_data = MysqLi_fetch_array($specgig_query); $specdate = stripslashes($specgig_data['date']); $specname = stripslashes($specgig_data['name']); $specevlink = stripslashes($specgig_data['evlink']); $specgigtick = stripslashes($specgig_data['ticklink']); $specnos = stripslashes($specgig_data['noshow']); if($specnos === '0'){ $noshow = ''; } else { $noshow = 'checked'; } ?> <table border-spacing: 5px; padding: 10px;"> <tr> <td> Past Event?: </td> <td text-align: left;"> <input type="checkBox" name="nos" <?PHP echo $noshow; ?> /> Past Event </td> </tr> <tr> <td> Date: </td> <td text-align: left;"> <input type="date" name="gigdate" value="<?PHP echo $specdate; ?>" required /> </td> </tr> <tr> <td> Name: </td> <td text-align: left;"> <input type="text" name="gigname" value="<?PHP echo $specname; ?>" required /> </td> </tr> <tr> <td> Event Page (Link): </td> <td text-align: left; width: 350px;"> <input type="url" name="giglink" width: 100%;" value="<?PHP echo $specevlink; ?>" /> </td> </tr> <tr> <td> Event Tickets (Link): </td> <td text-align: left; width: 350px;"> <input type="url" name="gigtick" width: 100%;" value="<?PHP echo $specgigtick; ?>" /> </td> </tr> </table><br /> <input type="hidden" name="gigid" value="<?PHP echo $gigtoed; ?>" /> <input type="submit" name="updgigs" value="Update" /><br /> <br /> <?PHP } if(isset($_POST['updgigs'])){ $newid = trim($_POST['gigid']); $newdate = MysqLi_real_escape_string($con,trim($_POST['gigdate'])); $newname = MysqLi_real_escape_string($con,trim($_POST['gigname'])); $newlink = MysqLi_real_escape_string($con,trim($_POST['giglink'])); $newtick = MysqLi_real_escape_string($con,trim($_POST['gigtick'])); if(isset($_POST['nos'])){ $newnoshow = MysqLi_real_escape_string($con,'1'); } else { $newnoshow = MysqLi_real_escape_string($con,'0'); } echo $newid.' '.$newdate.' '.$newname.' '.$newlink.' '.$newtick.' '.$newnoshow.'<br />'; /*MysqLi_query($con,"UPDATE `gigs` SET `date` = '$newdate',`name` = '$newname',`evlink` = '$newlink',`ticklink` = '$newtick',`noshow` = '$newnoshow' WHERE `idgigs` = '$newid' LIMIT 1") or die(MysqLi_error($con));*/ //commented for testing ?> <div text-align: center;"> <span class="confirm"> Successfully updated click <a href="index.PHP?page=events">here</a> to view it! </span> </div> <?PHP } ?> </form> </div> <?PHP }

仅供参考 – logincheck.PHP除了检查用户是否login之外没有任何作用,如果不是则将它们发送回主页。

Angular html5模式不能在Apache中工作

我在哪里把我的Hello world PHP文件放在Ubuntu上?

linux的msmtpconfiguration从shell发送,但是从PHP / apache失败

我无处不在地改变Apache的DocumentRoot无济于事

htaccess“命令”拒绝,允许,拒绝

如果任何用户输入项目以http://或https://开头,则您的网站会产生错误

当我尝试以http://开头的链接时,我得到了一个406不可接受:

http://onkore.us/?blah=http://www.google.com

当我尝试这个时候是很好的:

http://onkore.us/?blah=www.google.com

你已经提到过,如果它不止一个链接,那么你遇到了问题,但是当我尝试使用下面这样的两个链接的时候,它会很好:

http://onkore.us/?blah1=www.google.com&blah2=www.google.com

但是,无论您是否可以找到并解决可能特定于您的服务器配置的问题,或者您可以尝试解决

我不知道这个解决方法是否有帮助,但考虑到http://或https://正在创建问题,我在想的是从用户输入中删除http://和https:// 。 首先,您可能要尝试将<input type="url"更改为<input type="text"以避免强制使用URL格式。 然后,您可以使用Javascript在提交到服务器之前从表单中的用户输入中删除http://和https://出现次数。 另外,您可以在填充表单值之前从数据中删除这些数据。

希望这可以帮助 。

正则表达式: 如何从JavaScript中的URL中删除“http://”

这个错误意味着,例如,你问服务器的书籍(你只懂西班牙语)。 服务器只有英文和德文书籍。

因此,服务器有你的答案, 它不会给你,因为他知道你不会做任何有用的事情,否则你会做一些坏事! (比如不读书,扔给人头)。

406不可接受“是一种不寻常的状态代码 – 最常见的是200,404,500,301。当服务器出现问题时通常只会看到406,通常是愚蠢的,但很难诊断。

也:

这个一般的错误意味着你所做的请求被发现是一个潜在的黑客攻击服务器[…]

https://billing.stablehost.com/kNowledgebase/178/What-does-406-Not-Acceptable-mean.html

这个错误的最常见的解决方案与mod_security有关。

1. Mod_security

ModSecurity可以实时监控HTTP流量,以检测作为网络入侵检测工具的攻击。 ModSecurity也可以立即行动,以防止攻击到达您的Web应用程序。

这个406错误可能来自mod_security,可能是通过POST进行的攻击,传递一些url而不是纯文本和普通文本。

最常见的解决方案是在htaccess中禁用POST扫描和mod_security过滤:

<Ifmodulee mod_security.c> SecFilterEngine Off SecFilterScanPOST Off </Ifmodulee>

另外,在终端中,执行:

sudo a2dismod security2_module sudo service apache2 restart

取消激活ModSecurity

如果这不起作用,那么编辑文件

/etc/apache2/mod-security/modsecurity_crs_10_config.conf

添加一个#的开始有这样的行的开始:

SecDefaultAction “phase:2,log,deny,status:403,t:lowercase,t:replaceNulls,t:compressWhitespace”

最后,重新启动apache

sudo service apache2 restart

我一直有这个问题一段时间,只有一段时间,所以很难确定。

但是,经过一些测试,我发现我的错误。 它可能不在你的,但如果有人有406不可接受的错误,这是值得一试。

在我的情况下,每当发布的数据有'壳:'在其中发生错误,正如我所猜测的是解释错误,并引发错误。 我的解决方案是在发布之前替换该字符串。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐