Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.htaccess Passwordprtect基于查询字符串的php url_.htaccess_Password Protection - Fatal编程技术网

.htaccess Passwordprtect基于查询字符串的php url

.htaccess Passwordprtect基于查询字符串的php url,.htaccess,password-protection,.htaccess,Password Protection,我有一个CMS系统,它运行许多页面,为页面创建的url类似于CMS.php?id=xx,我只想使用htaccess对具有特定id(比如9)的页面进行密码保护,我在htaccess中几乎为零,因此如果代码有点解释性,这将有助于我。这应该会让你朝着正确的方向前进 <? //* Check for values in $PHP_AUTH_USER and $PHP_AUTH_PW */ if ((!isset($PHP_AUTH_USER)) || (!isset($PHP_A

我有一个CMS系统,它运行许多页面,为页面创建的url类似于CMS.php?id=xx,我只想使用htaccess对具有特定id(比如9)的页面进行密码保护,我在htaccess中几乎为零,因此如果代码有点解释性,这将有助于我。

这应该会让你朝着正确的方向前进

<?
    //* Check for values in $PHP_AUTH_USER and $PHP_AUTH_PW */

    if ((!isset($PHP_AUTH_USER)) || (!isset($PHP_AUTH_PW))) {

         //* No values: send headers causing dialog box to appear */
        header('WWW-Authenticate: Basic realm="My Private Stuff"');
        header('HTTP/1.0 401 Unauthorized');
        echo 'Authorization Required.';
        exit;

    } else if ((isset($PHP_AUTH_USER)) && (isset($PHP_AUTH_PW))){

        /* Values contain some values, so check to see if they're correct */

        if (($PHP_AUTH_USER != "validname") || ($PHP_AUTH_PW != "goodpassword")) {
                //* If either the username entered is incorrect, or the password entered is incorrect, send the headers causing dialog box to appear */
                header('WWW-Authenticate: Basic realm="My Private Stuff"');
                header('HTTP/1.0 401 Unauthorized');
                echo 'Authorization Required.';
                exit;
        } else if (($PHP_AUTH_USER == "validname") || ($PHP_AUTH_PW == "goodpassword"))  {
                //* if both values are correct, print success message */
                echo "<P>You're authorized!</p>";
        }
    } 
?>

这将根据需要弹出auth框=您可以在中添加一些额外的php逻辑,避免对我正在使用的开源CMS的核心攻击我无法在其文件中添加任何php代码,这就是为什么我提到我需要一个基于.htaccess的解决方案(如果我不清楚我的问题,请使用sry),但这必须是htaccess解决方案,而不是php代码。无论如何,谢谢你的回复。