0

すべて .htaccess パスワードで保護された CI プロジェクトがあります。.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>

この 2 つのどちらも機能しません。助けてくれてありがとう。

ルート フォルダーにあるメインの .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
4

1 に答える 1

3

単一の URL を許可するこの例を確認してください。 http://css-tricks.com/snippets/htaccess/allow-single-url/ このスニペットはさまざまなテスト環境を対象としていますが、サーバー上のファイルの場所ではなくURL に基づいて特定のリクエストを許可する方法を示しています。

于 2013-10-02T05:46:13.700 に答える