Forum Moderators: phranque
RewriteEngine on
RewriteCond %{HTTP_REFERER}!^$
RewriteCond %{HTTP_REFERER}!^http://(www\.)?example.com/.*$ [NC]
RewriteRule .*\.(jpg夸peg夙if如ng在mp)$ - [F]
RewriteEngine on
RewriteCond %{HTTP_REFERER} .
RewriteCond %{HTTP_REFERER} !^http://(www\.)?example\.com/ [NC]
RewriteRule \.(jpe?g夙if如ng在mp)$ - [F]
Flush your browser cache when testing... Change all broken pipes in code posted on WebmasterWorld to solid pipes before use; posting here modifies them.
Jim
Access control using HTTP_REFERER has this limitation. It's easy, and fairly effecitve, but you must allow blank referrers (or plan on hiring a full-time help desk and losing 15% of your legitimate visitors/sales/etc.) The 'cure' of blocking blank referrers is worse than the hotlinking 'disease' in most cases.
You can implement more sophisticated solutions using cookies and an image-serving script, or cookies and .htaccess restrictions. You can also cleverly rename your images once an hour/day/week, and use .htaccess to provide the correct image based on time. However, unless you are selling copyrighted images online, it's usually not worth the bother to develop and test these more-effective solutions.
There are hundreds of threads here about hotlinking (example [google.com]), and these issues are more fully discussed in many of them.
Jim
RewriteEngine on
RewriteCond %{HTTP_REFERER} \.$
RewriteCond %{HTTP_REFERER}!^http://(www\.)?example\.com/ [NC]
RewriteRule \.(jpe?g夙if如ng在mp)$ - [F] Do you think this will work all the time now?