httpd.conf DocumentRoot "/usr/local/www/apache24/data" <Directory "/usr/local/www/apache24/data"> Options Indexes FollowSymLinks AllowOverride All Require all granted </Directory> <Files ".ht*"> Require all denied </Files> /usr/local/www/apache24/data/.htaccess <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule>
- https://example.com/.httest → 403
- https://example.com/foo/.httest → 404
- https://example.com/wp-cotent/.httest → 403
Forbidden の部分ですがディレクトリそのものに対しての制限がかからない正規表現になっているので、例えば vendor ディレクトリであれば、
RewriteRule "^vendor/" - [F]は
RewriteRule "^vendor($|/)" - [F,NC]とした方がいいように思えます。
Apache の解説ではリダイレクトコードに 300-399 外を選択した場合は L が指定された場合と同様に書き換えが停止されるとあります。
nginx は分かりやすい
location ~ /\.ht { deny all; }