繁体   English   中英

如何配置Apache以允许在PHP中进行身份验证

[英]How to configure Apache to allow authentication in PHP

我的登录页面无法像在localhost中那样工作。 我重构了PHP页面和相关的脚本,但是在我在搜索中偶然发现Apache-PHP-module配置问题之前,没有任何效果。

我已在以下位置阅读并尝试了建议:

...但是他们都没有为我工作。 也许,我的问题很独特。 也许不吧。

到目前为止,.htaccess具有:

    <IfModule mod_rewrite.c>
     RewriteEngine On
     RewriteBase /
     RewriteRule ^index\.php$ - [L]
     RewriteCond %{REQUEST_FILENAME} !-f
     RewriteCond %{REQUEST_FILENAME} !-d
     RewriteRule . /index.php [L]
     </IfModule>

     RewriteEngine On
     RewriteRule .* - [env=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

RewriteCond %{HTTP_HOST} ^genieverse.com [NC]
RewriteRule ^(.*)$ http://www.my_site.com/$1 [L,R=301]

虽然log_in.php具有:

 //Get custom error function script
require_once('Server_Includes/scripts/common_scripts/feature_error_message.php');

if(preg_match('/Basic\s+(.*)$/i', $_SERVER['HTTP_AUTHORIZATION'],      $matches))
{ list($the_name,  $the_password) = explode(':', base64_decode($matches[1]));
$_SERVER['PHP_AUTH_USER'] = strip_tags($the_name);
$_SERVER['PHP_AUTH_PW'] = strip_tags($the_password); }
//Filter incoming values
$username    =    (isset($_POST["username"])) ? trim($_POST["username"])    :     "Username";
$password = (isset($_POST["password"])) ? trim($_POST["password"])    :    "Password";

.....其余部分继续到log_in页面表单。

每当我输入用户名和密码,然后单击提交时,登录页面重新加载,要求输入相同的名称。 就像他们从未被发送过一样。

我到底需要做什么?

PS:Web服务器为共享托管,Apache 2.2.31,PHP 5.4.45

没关系。 我已经解决了。:我上传了一个自定义php.ini文件。 它包括:session.auto_start =开

但这没有用。 htaccess hack的任何形式都没有。 所以我用以下命令创建了一个phpinfo.php文件:

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM