LoginSignup
3
6

More than 5 years have passed since last update.

特定のファイルのみベーシック認証をかけたい場合の.htaccess

Last updated at Posted at 2015-03-22

特定ファイルのみベーシック認証をかけたい場合。

<Files ~ "^\.(htaccess|htpasswd)$">
deny from all
</Files>
AuthUserFile /home/hoge/html/.htpasswd
AuthGroupFile /dev/null
AuthName "Please enter your ID and password"
AuthType Basic
order deny,allow
<Files test.html>
require valid-user
</Files>

参考にディレクトリ単位のものも。
後半のFilesがいりません。

<Files ~ "^\.(htaccess|htpasswd)$">
deny from all
</Files>
AuthUserFile /home/hoge/html/.htpasswd
AuthGroupFile /dev/null
AuthName "Please enter your ID and password"
AuthType Basic
order deny,allow
require valid-user
3
6
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
6