以前用xiaoz的Zdir很方便,可是没有密码,最近VPS保存了私人的内容,不想被被人看到,所以换成了H5ai进行加密

登录宝塔后台在网站目录下找到_h5ai/public/index.php
在第一行<?php下面添加:

auth();

然后再最底部加上:

function auth ()
{
        $valid_passwords = array ("账号" => "密码");
        $valid_users = array_keys($valid_passwords);

        $user = $_SERVER['PHP_AUTH_USER'];
        $pass = $_SERVER['PHP_AUTH_PW'];

        $validated = (in_array($user, $valid_users)) && ($pass == $valid_passwords[$user]);

        if (!$validated) {
          header('WWW-Authenticate: Basic realm="My Realm"');
          header('HTTP/1.0 401 Unauthorized');
          die ("Not authorized");
        }
}

账号,密码是你自己设定的账号和密码!
文章转自Rat's BLog