1

我正在使用Phil Sturgeon 的 library构建一个 RESTful 服务。它在本地主机(Windows 7,WAMP 服务器)上就像一个魅力。但是在 Web 服务器 (CentOS) 上部署时,我无法获得基本身份验证。我尝试在第 880 行修改 REST_Controller.php:

protected function _check_login($username = '', $password = NULL)
{
    $this->response(array("username"=>$username, "password"=>$password));
    if (empty($username))
    {
        return FALSE;
    }
...

响应中的用户名和密码均为空。谁能告诉我如何解决这个问题?提前致谢!

[更新] 我在这里找到了答案:http ://www.sslcatacombnetworking.com/articles/http-authentication-php-cgi.html

4

1 回答 1

0

我在这里找到了答案:http ://www.sslcatacombnetworking.com/articles/http-authentication-php-cgi.html [更新]

第 1 步: 使用文本编辑器(如 Windows 记事本)创建纯文本文件。

第 2 步: 添加以下文本...

<IfModule mod_rewrite.c>
     RewriteEngine on
     RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
</IfModule>

第 3 步: 将文件另存为纯文本文件。将文件命名为“.htaccess”

第 4 步: 使用 FTP 应用程序以 ASCII 模式将 .htaccess 文件上传到您的网络空间。

第 5 步:在您的用户/通过检查例程之前,在您的 PHP 脚本中添加以下内容。

list($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']) = explode(':', base64_decode(substr($_SERVER['HTTP_AUTHORIZATION'], 6)));
于 2012-06-16T12:45:06.240 回答