PHP/Apache错误:406不可接受

iam*_*der 6 php mysql apache

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

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

一切都在膨胀,我手动将数据输入MySQL,让它自动提供给主页.现在我正在添加控制面板,以便我可以从Web添加,编辑和删除数据库中的内容.

除了添加/编辑事件的能力之外,一切正常.我把它缩小到我无法输入2个URL或我收到此错误的事实.我需要输入2个网址(一个用于查看活动页面,一个用于购买门票)但我一次输入的数量不能超过1个,是否有任何我可以做的纠正或解决此错误,无论是在apache还是我的码?

<?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 style="text-align: left;">
                          <input type="url" name="giglink" value="<?php echo $specevlink; ?>" />
                     </td>
                </tr>
                <tr>
                     <td>
                          Event Tickets (Link):
                     </td>
                     <td style="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>
Run Code Online (Sandbox Code Playgroud)

编辑:

我正在添加完整的代码行,以便您可以确切地看到我正在使用的代码,

这是第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 style="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" style="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 style="border-spacing: 5px; padding: 10px;">
                <tr>
                     <td>
                          Past Event?:
                     </td>
                     <td style="text-align: left;">
                          <input type="checkbox" name="nos" <?php echo $noshow; ?> /> Past Event
                     </td>
                </tr>
                <tr>
                     <td>
                          Date:
                     </td>
                     <td style="text-align: left;">
                          <input type="date" name="gigdate" value="<?php echo $specdate; ?>" required />
                     </td>
                </tr>
                <tr>
                     <td>
                          Name:
                     </td>
                     <td style="text-align: left;">
                          <input type="text" name="gigname" value="<?php echo $specname; ?>" required />
                     </td>
                </tr>
                <tr>
                     <td>
                          Event Page (Link):
                     </td>
                     <td style="text-align: left; width: 350px;">
                          <input type="url" name="giglink" style="width: 100%;" value="<?php echo $specevlink; ?>" />
                     </td>
                </tr>
                <tr>
                     <td>
                          Event Tickets (Link):
                     </td>
                     <td style="text-align: left; width: 350px;">
                          <input type="url" name="gigtick" style="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 style="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
}
Run Code Online (Sandbox Code Playgroud)

仅供参考 - logincheck.php什么都不做,只检查用户是否已登录,如果没有,则将其发送回主页.

Tom*_*ado 5

例如,此错误意味着您向服务器索要书籍(而您只懂西班牙语)。服务器只有英文和德文书籍。
因此服务器有你的答案,它不会给你,因为他知道你不会做任何有用的事情,或者你会用它做坏事!!(例如,不阅读书籍并将其扔到人们的头上)。

406 Not Acceptable” 是一个不寻常的状态代码 - 最常见的是 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 流量以检测攻击 [...] 它作为 Web 入侵检测工具运行。ModSecurity 还可以立即采取行动,防止攻击到达您的 Web 应用程序。

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

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

<IfModule mod_security.c>
SecFilterEngine Off
SecFilterScanPOST Off
</IfModule>
Run Code Online (Sandbox Code Playgroud)

此外,在终端中,执行:

sudo a2dismod security2_module 
sudo service apache2 restart 
Run Code Online (Sandbox Code Playgroud)

停用 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


Uou*_*urs 5

如果任何用户输入项以http://或中的任何一个开头,则您的网站会生成错误https://.

当我尝试使用链接时,http://我得到了406 Not Acceptable:

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://"