I'm trying to block the Apache icons folder from remote access. Blocking by IP does not hack it so I've been trying the following:
RewriteCond %(REQUEST_URI) ^/icons/
(with and without leading ^ and /)
...followed by ONE of the following (none work)...
RewriteRule - - [F]
RewriteRule ^/icons/(\.(gif|jpg|png))$ - [F,NC]
RewriteRule \.(gif|jpg|png)$ - [F,NC]
RewriteRule /icons/ - [R=403,F]
The Apache docs and sundry online forums suggest I'm using the correct syntax but I can still load a selected icon in a browser.
Obviously I have something wrong but what? Help appreciated.
Abreviated htaccess file is:
#========
# security policies
#Secure cookies: in config editor section system.web/httpcookies set
#httpOnlyCookies true
#requireSSL true
Header set Strict-Transport-Security "max-age=15552001; includeSubDomains; preload"
Header set X-Frame-Options "SAMEORIGIN"
Header set X-Xss-Protection "1; mode=block"
Header set X-Content-Type-Options "nosniff"
Header set X-Permitted-Cross-Domain-Policies "none"
Header set Referrer-Policy "strict-origin-when-cross-origin"
Header set Content-Security-Policy "default-src 'none'; style-src 'self'; child-src 'self'; frame-ancestors 'self'; base-uri 'self'; script-src 'self'; form-action 'self'; img-src 'self'; object-src 'none'; block-all-mixed-content;"
Header set Expect-CT "enforce,max-age=30"
#========
# geo-block
GeoIPEnable On
#GeoIPDBFile /usr/share/GeoIP/GeoIP.dat Standard # cannot use in htaccess
SetEnvIf GEOIP_COUNTRY_CODE BR BlockCountry
(and others)
Deny from env=BlockCountry
#========
SetEnvIfNoCase User-Agent "urlwatch" dontlog
#========
order allow,deny
#========
(various deny from IP lines)
#========
RewriteEngine on
#========
# apache icons (as above code)
#========
# reject hotlinking
#RewriteBase /
#RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^https://mail\.bristolweb\.net/ [NC]
RewriteRule \.(ico|pdf|flv|jpg|jpeg|mp3|mpg|mp4|mov|wav|wmv|png|gif|swf|css|js)$ - [F,NS]
#========
# block some simple UA substrings
RewriteCond %{HTTP_USER_AGENT} ^ht[tm][lpr] [NC]
RewriteRule . - [F]
# only allow get/post/http/1.1
#RewriteCond %{THE_REQUEST} !^(POST|GET)\ /.*\ HTTP/1\.1$ [NC]
RewriteCond %{REQUEST_METHOD} !^(GET|POST)
RewriteRule .? - [F]
# only allow https
RewriteCond %{HTTPS} on
RewriteRule . - [F]
# allow urlwatch
RewriteCond %{HTTP_USER_AGENT} ^urlwatch/
RewriteRule . - [L]
# only allow mozilla 5
RewriteCond %{HTTP_USER_AGENT} !^Mozilla/5\.0
RewriteRule . - [F]
# not old firefox
RewriteCond %{HTTP_USER_AGENT} Firefox/[0-9]\.|Firefox/[0-5][0.9]\.|Windows\sNT\s[0-5] [NC]
RewriteRule . - [F]
# not initial symbols
RewriteCond %{HTTP_USER_AGENT} ^[\"\'$%&*()-=+_@~#{}[]<>,.?/|\\\!] [NC]
RewriteRule . - [F]
RewriteCond %{HTTP_USER_AGENT} (agent|analy[sz]|anonymous|archive|bandit|bot|brand|cherrypicker|clshttp|collector|compatible;[a-z]|craftbot|crawl|curl|deepnet|discover|download|explorer|extract|file|grab|greasemonkey|harvest|indy\slibrary|java|larbin|le[ae]ch|legs|link|lynx|mail|miner|netcraft|ninja|n[-_\s]?u[-_\s]?t[-_\s]?c[-_\s]?h|open|perl|php|proxy|python|ripper|script|search|seo|shodan|sitemap|snoop|sph?ider|stripper|sucker|survey|sweep|torrent|webpictures|webspider|worm) [NC]
RewriteRule . - [F]
#========
allow from all
#========