Forum Moderators: phranque
[edited by: keyplyr at 6:45 am (utc) on Feb 11, 2017]
RewriteCond %{HTTP_REFERER} ^http://(.+\.)?blogspot [OR]
RewriteRule .*\.(jpe?g|gif|bmp|png)$ - [F,L]
I see in my log that they continue to receive successful 200s and download the image, even when the image no longer exists
RewriteCond %{HTTP_REFERER} blogspot [OR]...
RewriteRule (jpe?g|gif|bmp|png)$ - [F]
-deleted my hotlinked image *beetle.jpg, 37.4k
183.171.87.204 [12/Feb/2017:01:30:19 GET /*stuff/*beetle.jpg HTTP/1.1 200 435 [*.blogspot.my...] Mozilla/5.0 (Linux; Android 4.4.2; ASUS_T00K Build/KVT49L) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/30.0.0.0 Mobile Safari/537.36
183.171.87.204 [12/Feb/2017:01:30:40 GET /*stuff/*beetle.jpg HTTP/1.1 200 435 [*.blogspot.my...] Mozilla/5.0 (Linux; Android 4.4.2; ASUS_T00K Build/KVT49L) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/30.0.0.0 Mobile Safari/537.36
Did you skip a line here? You can't put [OR] at the end of your last condition, or the rule will always execute. (Guess how I know this.) And, by your post, this does not seem to be the case.
If an error is returned, why would my server log a 200 code?
ErrorDocument 403 /403.php
RewriteRule ^(403\.php|nohotlinks\.png) - [L]
listing all error documents, along with anything that functions equivalently. You need this to prevent infinite loops.)
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /xxx/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wp/index.php [L]
</IfModule>
# END WordPress
107.167.112.188 [13/Feb/2017:01:08:26 GET /stuff/*beetle.jpg HTTP/1.1 200 435 http://*.blogspot.de/2013/08/updated-kaget-banget-lipstick-baruku.html?m=1 Opera/9.80 (Android; Opera Mini/21.0.2254/37.9389; U; id) Presto/2.12.423 Version/12.16
168.235.201.61 [13/Feb/2017:01:45:04 GET /stuff/*beetle.jpg HTTP/1.1 403 637 http://*.blogspot.de/2013/08/updated-kaget-banget-lipstick-baruku.htmlMozilla/5.0 (Linux; U; Android 5.0.2; en-US; Redmi Note 3 Build/LRX22G) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 UCBrowser/10.7.2.645 U3/0.8.0 Mobile Safari/534.30
124.153.33.7 [12/Feb/2017:23:05:46 GET /stuff/*beetle.jpg HTTP/1.1 403 635 http://*.blogspot.co.id/2013/08/updated-kaget-banget-lipstick-baruku.html Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36
118.96.234.231 [13/Feb/2017:02:02:46 GET /stuff/*beetle.jpg HTTP/1.1 200 435 http://*.blogspot.co.id/2013/08/updated-kaget-banget-lipstick-baruku.html Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36
[edited by: phranque at 2:48 am (utc) on Mar 14, 2017]
[edit reason] unlinked urls for clarity [/edit]
UAs and referrers are often not what/who they say they are so they aren't going to always be effective
My site is set up as
RewriteCond %{HTTP_REFERER} blogspot [OR]
RewriteCond %{HTTP_REFERER} ^http://(.+\.)?treponregos [NC]
RewriteRule (jpe?g|gif|bmp|png)$ - [F]
SetEnvIf Referer (blogspot|treponregos)$ trash deny from env=trash PS If you add lines to the htaccess file where your WP section is, make sure the additional lines are before that WP part, not after.
RewriteCond %{HTTP_REFERER} blogspot [OR]
RewriteCond %{HTTP_REFERER} treponregos [NC]
RewriteRule (jpe?g|gif|bmp|png)$ - [F]
120.188.76.233 [13/Feb/2017:13:21:15 GET /stuff/*beetle.jpg HTTP/1.1 403 637 [*.blogspot.de...] Mozilla/5.0 (Linux; U; Android 5.1.1; en-US; F1f Build/LMY47V) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 UCBrowser/11.2.0.915 U3/0.8.0 Mobile Safari/534.30
180.248.22.157 [14/Feb/2017:01:21:07 GET /stuff/*beetle.jpg HTTP/1.1 200 435 [*.blogspot.de...] Mozilla/5.0 (Linux; U; Android 4.4.2; en-US; E1C Pro Build/KOT49H) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 UCBrowser/11.0.0.828 U3/0.8.0 Mobile Safari/534.30
103.47.133.0 [13/Feb/2017:12:22:35 GET /stuff/*beetle.jpg HTTP/1.1 403 635 [*.blogspot.co.id...] Mozilla/5.0 (Linux; Android 6.0.1; SAMSUNG SM-A800F Build/MMB29K) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/4.0 Chrome/44.0.2403.133 Mobile Safari/537.36
64.233.173.10 [13/Feb/2017:21:50:13 GET /stuff/*beetle.jpg HTTP/1.1 200 435 [*.blogspot.co.id...] Mozilla/5.0 (Linux; Android 5.1.1; A37f Build/LMY47V) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.91 Mobile Safari/537.36
SetEnvIf User-Agent "blogspot " keep_out
Order Allow,Deny
Allow from all
Deny from env=keep_out
...Too often, mod_rewrite is like shooting flies with an elephant rifle. There's a reason the apache docs are always urging you to use some other mod (even if it's completely unrealistic for most people in most situations).
I am able to block a few of their IPs with deny from statements, but they come up as 500s.
112.215.174.196 [14/Feb/2017:05:27:22 GET /stuff/*rash2.jpg HTTP/1.1 500 - http://2*.blogspot.co.id/2012/08/miliaria.html?m=1
114.121.237.179 [13/Feb/2017:13:33:20 GET /stuff/*rash2.jpg HTTP/1.1 500 -http://2*.blogspot.co.id/2012/08/miliaria.html?m=1
8.37.225.89 [14/Feb/2017:00:58:23 GET /stuff/*beetle.jpg HTTP/1.1 500 - http://*.blogspot.de/2013/08/updated-kaget-banget-lipstick-baruku.html deny from 112.215.170.0/23 112.215.172.0/22
deny from 114.121.232.0/21
deny from 8.37.225.0/24
PS If you add lines to the htaccess file where your WP section is, make sure the additional lines are before that WP part, not after.Thanks for the tip Not2Easy.
Why is it better to add additional rewrite rules before the WP part?The reason is that WP's htaccess modifies the incoming URL, and then executes it. If you add your rewrite rules after the WP part, the incoming url will be modified and executed before it gets to your additional rewrite rule, meaning your rewrite rule will never be executed.