<Limit GET POST HEAD>
Order allow,deny
Allow from all
</Limit>
<Limit PUT DELETE PATCH>
Order deny,allow
Deny from all
</Limit>
Order、Allow、Deny 針對 IP/網域限制allow from .example.com 符合 sub.example.com)allow from 192.168 符合 192.168.x.x)DirectoryIndex index.html index.php index.htm default.html
Options Indexes 開啟 → 顯示目錄列表Options Indexes 關閉 → 回傳 403 ForbiddenAccessFileName .htaccess
.htaccess.acl),但需對應修改 AllowOverride<Files ".htaccess">
Order allow,deny
Deny from all
</Files>
<FilesMatch "\.(bak|config|sql|log)$">
Order allow,deny
Deny from all
</FilesMatch>
.htaccess, .htpasswd, *.bak, *.sql, *.log) 被直接下載FilesMatch 支援正則表達式,更靈活# CacheNegotiatedDocs
UseCanonicalName On
ServerName + Port 建構的規范 URL,確保瀏覽器地址列一致httpd.conf / apache2.conf<VirtualHost> 覆蓋<Directory> / <Location> 進一步細化.htaccess 最後套用 (若 AllowOverride 允許)子目錄繼承父目錄設定,AllowOverride None 可阻斷 .htaccess 讀取,提升效能與安全。