【发布时间】:2013-10-02 05:17:07
【问题描述】:
我有一个 CI 项目,全部受 .htaccess 密码保护。 .htaccess 密码保护是从根文件夹设置的。但是由于它为移动应用程序提供了一个 API,因此必须为此目的取消对特定控制器的保护,以便移动设备可以与该特定控制器进行通信。
最好的方法是什么?
我尝试在根文件夹中的主 .htaccess 中添加以下内容。
<Files "/home/path/to/project/root/my_specific_controller">
Allow from all
Satisfy any
</Files>
还尝试了以下 .htaccess 放入控制器文件夹本身。
<Files "my_specific_controller"> # this is the name of my CodeIgniter controller
Allow from all
Satisfy any
</Files>
这两个都不起作用。感谢您的帮助。
根文件夹中的主.htaccess文件现在是这样的:
RewriteEngine On
RewriteBase /project/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule ^(.*)$ index.php/$1 [L]
RewriteRule ^(.*)$ index.php/$1 [L]
<Files "/home/path/to/project/root/my_specific_controller">
Allow from all
Satisfy any
</Files>
AuthType Basic
AuthName "Pswd Protected Area"
AuthUserFile /home/path/to/project/root/.htpasswd
Require valid-user
【问题讨论】:
标签: apache .htaccess codeigniter