Forum Moderators: phranque
SetEnvIfNoCase Request_URI robots\.txt$ OKFILE
SetEnvIfNoCase Request_URI (401|403|404).php$ OKFILE
#=============
SetEnvIf Remote_Addr ^23\.(19|2[0-3])\. BLOCK
SetEnvIf Remote_Addr ^199\.212\. BLOCK
# ... more ip/UA/etc. tests
#=============
# Always Allow from ME ! (in case I block myself, above)
SetEnvIf Remote_Addr ^xx\.xx\.xx\xx MYIP
#=====================
# #1 Deny with rewrite_module
#.....................
# Kill bad requests, unless OKFILE or ME
RewriteCond %{ENV:BLOCK} 1
RewriteCond %{ENV:OKFILE} !1
RewriteCond %{ENV:MYIP} !1
RewriteRule ^(.*)$ - [F,L]
#=====================
# #2 Deny with authz_host_module
#.....................
<Files *>
Order deny,allow
Deny from env=BLOCK
Allow from env=OKFILE
Allow from env=MYIP
# No match: Default to second directive: Allowed
# Match both Allow & Deny: Final match controls: Allowed
</Files>
#=====================
# ? Which is Better/Best?
#.....................
RewriteCond %{ENV:BLOCK} 1
RewriteCond %{ENV:OKFILE} !1
RewriteCond %{ENV:MYIP} !1