LoginSignup
3
3

More than 3 years have passed since last update.

Apache2.4のhtaccessで複数条件を組み合わせる時の注意点

Last updated at Posted at 2016-09-28

Apache2.4の.htaccess設定メモ

IP制限を掛けつつ、ダイジェスト認証を設定する
<RequireAll>を使わずに並列に「IP制限」と「認証」を書くと<RequireAny>として扱われるため、
「IP制限」または「認証」となってしまうので注意。

ディレクティブ 意味
<RequireAll> ディレクティブ内の条件すべてに一致することを要求する
<RequireAny> ディレクティブ内の1つ以上の条件に一致することを要求する
未指定 <RequireAny> と同義
# IP制限かつ認証要求
<LocationMatch "/hoge/admin.*">
    <RequireAll>
        <RequireAny>
            Require ip xxx.xxx.xxx.xxx
        </RequireAny>

        AuthType Digest
        AuthName "test"
        AuthUserFile xxxxxx
        Require valid-user
    </RequireAll>
</LocationMatch>

これで指定されたIPのどれかに一致、かつ認証通過を要求となります。

3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3