htaccess

[htaccess]BASIC認証とIP一部IPのみ制限

/var/www/xxxxx/public_htmlはBASIC認証又はIPが192.168.xxx.xxxならば閲覧可能
/var/www/xxxxx/public_html/secureはIPが192.168.xxx.xxxならば閲覧可能。それ以外のIPは403

/var/www/xxxxx/public_html/.htaccess

AuthUserFile /var/www/xxxxx/public_html/.htpasswd
AuthGroupFile /dev/null
AuthName "Input ID and Password."
AuthType Basic
require valid-user
SetEnvIf Request_URI "^/secure/.*$" secure_dir
Order Deny,Allow
Deny from all
allow from env=secure_dir
Allow from 192.168.xxx.xxx
<Files ~ "^\.(htaccess|htpasswd)$">
deny from all
</Files>
Satisfy Any

/var/www/xxxxx/public_html/secure/.htaccess

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REMOTE_ADDR} !^192.168.xxx.xxx
RewriteRule ^(.*)$ - [R=403,L]
</IfModule>