某些文件返回错误 520

1 php .htaccess http-error

我的网络服务器中的一些文件正在返回Error 520: Web server is returning an unknown error。据我所知,返回错误的文件是index.phpgoogle0f3d9b***.html(用于验证 Google 网站管理员控制台)。

以下是我的.htaccess文件:

RewriteBase /

# Force non-www version
RewriteCond %{HTTP_HOST} ^www\.yikjin\.ga [NC]
RewriteRule ^(.*)$ https://yikjin.ga/$1 [L,R=301]

# Prevent 000webhost ads from poping up
php_value auto_append_file none

# Prevent directory listing
Options -Indexes

# Make index.php default
DirectoryIndex index.php
Run Code Online (Sandbox Code Playgroud)

和我的index.php

<!DOCTYPE html>
<html>
<head>
    <!-- ... -->
</head>

<body>
<header>
    <img src="/drawable/images/me.jpg" width="6%" alt="That's us!" title="That's us!">
    <span>Welcome to Cards!</span>
</header>

<div id="login">
    <img src="/drawable/images/cards.jpg" alt width="40%" height="auto">
    <h2 id="welcome">Welcome back,<br/>
        <span id="user">user</span>
    </h2>
    <h4>Please re-enter your password</h4>
    <form method="post">
        <label for="userid">Username</label>
        <br/>
        <input type="text" title="What's your username?
   eg. johntan" id="userid" name="userid" required>
        <br/>
        <span id="user-err"></span>
        <br/>
        <label for="pass">Password</label>
        <br/>
        <input type="password" title="What's your password?
   eg. *****" id="pass" name="pass" required>
        <br/>
        <span id="pass-err"></span>
        <br/>
        <input type="button" value="&lsaquo; Back" onclick="javascript:window.history.back();">
        <input type="submit" value="Continue &rsaquo;" name="login">
        <a href="#" target="_blank">Not you?</a>
    </form>
    <br/>
    <a href="/register.php">Register now</a>
</div>

    <link href="/drawable/css/design.css" type="text/css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css?family=Open+Sans:300" type="text/css" rel="stylesheet">

<!-- Begin Cookie Consent -->
<script type="text/javascript">
    window.cookieconsent_options = {"message":"We love cookies. So we use them. :D","dismiss":"Got it!","learnMore":"Whyyy...","link":null,"theme":"dark-bottom"};
</script>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/cookieconsent2/1.0.9/cookieconsent.min.js"></script>
</body>
</html>

<?php
    include("/drawable/connect.php"); /* $dbcon is from this file */

    if (isset($_POST['login'])) {
        $userid = $_POST['userid'];
        $pass = $_POST['pass'];

        $check_user = "SELECT * FROM login WHERE userid = '$userid' AND password = '$pass'";
        $user_query = mysqli_query($dbcon, $check_user);

        if (mysqli_num_rows($user_query)) {
            $_SESSION['user'] = $userid;
            header("Location: welcome.php");
        }
        else {
            echo "<script>alert('Invalid credentials supplied; please retry');</script>";
        }
    }
?>
Run Code Online (Sandbox Code Playgroud)

我认为这是我的文件的问题.htaccess,但我似乎无法弄清楚是什么。我使用 000webhost 作为我的 Web 服务器和 Cloudflare。我网站的链接是yikjin.ga。我可以知道是什么原因导致网站无法运行吗?提前致谢!

Pan*_*nda 5

正如 CloudFlare 文档中引用的那样:

\n\n
\n

520 错误本质上是 \xe2\x80\x9ccatch-all\xe2\x80\x9d 响应。

\n
\n\n

这可能是由以下情况引起的:

\n\n
    \n
  • 连接重置(TCP 握手成功后)
  • \n
  • 标头超出 CloudFlare\xe2\x80\x99s 标头大小限制
  • \n
  • 来自原点的空响应
  • \n
  • 无效的 HTTP 响应
  • \n
  • HTTP 响应缺少响应标头
  • \n
\n\n

来源:CloudFlare 错误 520 文档

\n\n
\n

当 CloudFlare 无法与 website\xe2\x80\x99s 源服务器建立 TCP 连接时,会返回 522 错误响应。

\n
\n\n

这可能是由以下情况引起的:

\n\n
    \n
  • 对来自 CloudFlare IP 的传入连接进行速率限制。
  • \n
  • Web 服务器上的进程正在消耗源处的所有一个或多个资源。
  • \n
  • 该域位于共享托管平台上,同一服务器上单独域的流量或任务占用一个或多个资源。
  • \n
  • CloudFlare 和源 Web 服务器之间的网络连接问题。
  • \n
\n\n

来源:CloudFlare 错误 522 文档

\n\n

对于您的情况,很可能是服务器超时或 DB CONN 有问题。您可以尝试将 DB CONN 移动到文件中而不是包含它。

\n\n

建议在开发时关闭 CloudFlare,以便更轻松地诊断站点的任何问题。

\n