Learn how to block people from hotlinking to your resources.
Hi. Sean here. We’re going over how to protect your site against hotlinking. What is hotlinking? If you’re watching this video you may know already and basically hotlinking is somebody stealing your bandwidth.
You have an image up on your website that somebody else likes and they just link to it from their website and they don’t actually copy the image over to their website, so when their website loads the image, it loads off your server here and that’s why it’s basically like stealing bandwidth and so there are ways to protect against that.
Get logged in to the ACC and click on Files and then Web, navigate to the directory of the website you want to put hotlinking on and then we’re gonna go up here to Web Settings. Click on that and then if you already have a .htaccess file, it’ll say Edit Your .htaccess File. We don’t have one yet so we’re going to create one and then there’s a snippet of code we need to put in here. Okay here’s this code and this is all done through something called “mod rewrite” which is an Apache based tool and the first thing it needs to be in there is rewrite engine on and then we have a couple of rewrite conditions and then we have a rewrite rule.
So this first rewrite condition checks the referrer information and those three little symbols there: the exclamation point, the caret, and then the dollar sign – that indicates an empty referrer field and the next rewrite condition here is basically looking to see if the referrer that’s asking for the image the referrer information if it’s your website.
So in this example here we’re using example.com and if that’s the name of your website that would work here. So you want to replace example.com with your actual domain name. Then we have the rewrite role and you could see there’s some image format file name extensions here: jpg, jpeg, png, gif – some of the more common image formats, so any requests to files that end in that are then going to be given a forbidden message and that’s what this F means here. Basically it will say forbidden, you’re not allowed to access this image. And the L means the last role and it basically stops – the rewrite engine stops doing what it’s doing and hands the process back to Apache to do what it needs to do.
So once we have that all in there remember to change example.com to your domain name. We click Create File and there we go. Our changes have been saved. That’s all there is to it. If you have any questions check out kb.pair.com or email us at firstname.lastname@example.org. Have a great day.