Mobile app version of vmapp.org
Login or Join
Sent6035632

: First I would adjust the code slightly so that its more like this: RewriteCond %{HTTP_REFERER} !^(|(http(|s)://))(mySite1|mySite2|ask|bing|duckduckgo|google|ixquick|msn|startpage|yahoo).com$ [NC,OR] RewriteCond

@Sent6035632

First I would adjust the code slightly so that its more like this:

RewriteCond %{HTTP_REFERER} !^(|(http(|s)://))(mySite1|mySite2|ask|bing|duckduckgo|google|ixquick|msn|startpage|yahoo).com$ [NC,OR]
RewriteCond %{HTTP_REFERER} ^$
RewriteCond %{REQUEST_URI} ^.*.(bmp|gif|ico|jpg|jpeg|pdf|png|svg|svgz|swf)$ [NC]
RewriteRule ^(.*)$ i.imgur.com/qX4w7.gif [R=301,NC,L]


How visitors are being blocked

The first line in the code means search for a pattern that may start with , or no prefix, then add to the search query any of: mySite1, mySite2, ask, bing, duckduckgo, google, ixquick, msn, startpage, yahoo, then add .com. If a match is found, then go to the image extension check. Otherwise check for an empty referrer string and if it matches, then continue to the image extension check.

If the URL (minus domain) contains any of: .bmp, .gif, .ico, .jpg, .jpeg, .pdf, .png, .svg, .svgz or swf, and the referrer check is true then all requests that match are redirected to i.imgur.com/qX4w7.gif.
Why redirecting to image on another server may be bad

Also, with your method, when users come from an unauthorized URL such as facebook, they will see the image, but the image is on another server unless you're running imgur.com. The downfall to this is if that server goes down and someone without authorization wants an image, they will either end up with a 404 page from imgur.com or a 500 internal server error page, or the browser may hang (depending on the bad health of imgur.com).

Another reason its bad to link to a remote image to handle error is because the image on a remote server could change at any time, especially if you have no authorization to manage the image file. You wouldn't want the image to show the hotlink message one day as intended and the next day, it suddenly switches over to a picture of a country flag, would you?

What you should do instead is make a much simpler image that takes up almost no space (like less than 1 KB). Try a static GIF that's no more than 200px wide by 200px high and that contains no more than a few colors. Then upload that image to your server and use it instead of one from imgur.com.

That way, if everything else crashes around you then people without authorized access to the images will see the simpler image (hot-linking message) when they want the protected images.

10% popularity Vote Up Vote Down


Login to follow query

More posts by @Sent6035632

0 Comments

Sorted by latest first Latest Oldest Best

Back to top | Use Dark Theme