【问题标题】:Password Protection with htaccess with Yii Framework使用 Yii 框架使用 htaccess 进行密码保护
【发布时间】:2015-07-27 08:11:50
【问题描述】:

我正在尝试使用用户名和密码保护我的网站。

这是我在添加密码保护之前的 .htaccess

 RewriteEngine on

 # if a directory or a file exists, use it directly
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-d
 # otherwise forward it to index.php
 RewriteRule . index.php

我在文件末尾添加了以下代码

 AuthType Basic
 AuthName "Password Protected Area"
 AuthUserFile .htpasswd
 Require valid-user

所以我的 .htaccess 目前是 重写引擎开启

 # if a directory or a file exists, use it directly
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-d
 # otherwise forward it to index.php
 RewriteRule . index.php

 AuthType Basic
 AuthName "Password Protected Area"
 AuthUserFile .htpasswd
 Require valid-user

密码保护工作正常,但网站返回内部错误 500

为什么密码保护取消了重写引擎部分?请指教。

【问题讨论】:

标签: .htaccess yii


【解决方案1】:

我已经添加了“.htpasswd”的完整路径来解决这个问题

AuthUserFile "/home/folder/folder/.htpasswd"

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-05-07
    • 2023-04-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-14
    相关资源
    最近更新 更多