【问题标题】:Remove .htaccess password protection from specific controller从特定控制器中删除 .htaccess 密码保护
【发布时间】: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


    【解决方案1】:

    查看这个允许单个 URL 的示例。 http://css-tricks.com/snippets/htaccess/allow-single-url/ 虽然这个 sn-p 针对不同的测试环境,但它展示了如何允许特定的请求基于 URL,而不是服务器上的文件位置。

    【讨论】:

      猜你喜欢
      • 2015-10-19
      • 1970-01-01
      • 1970-01-01
      • 2010-11-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-20
      相关资源
      最近更新 更多