Understanding Hotlinks
A Hotlink is where someone displays an image on their site which is actually located on your site by using a direct link to the source of the image on your server.
Due to the fact that the image being displayed on the other person’s site is coming from your server, this can cause leaking of bandwidth and resources for you because your server has to present this image for the people viewing it on someone else’s site.
When this happens, you – the original website owner must cover and pay for these server resources each time a web browser wants to load and view the asset.
For example, Website Y’s owner found a funny meme or video on Jane’s website and decided to use it on their website. But instead of re-uploading the file on their server, the owner of Website Y links the image/video directly from Jane’s website to instantly show it on their site.
Even though people can see it on Website Y, the origin server is still storing it. In other words, server resources from Jane’s website are used every time a user views this hotlinked image or video.
Consequently, If Website Y receives high traffic, a significant amount of Jane’s website server resources will be used.
How to Protect Your Site From Getting Hotlinked
Putting hotlink protection in place is very important to prevent issues related to content and bandwidth theft.
Method 1: Via FTP(File Transfer Protocol)
An option is to edit your website’s .htaccess file by accessing it through an FTP client like FileZilla or the file manager on your DirectAdmin control panel.
Note that this method involves editing your website’s code, so be careful – a small error can render your site unusable.
- Once you’ve connected to your website’s FTP or opened up the file manager, navigate to the public_html folder.
- Within the public_html folder, find the .htaccess file and download it.
- On your computer, make a copy of the original .htaccess file in case something goes wrong.
- Open the .htaccess file using your preferred text editor.
- Copy and paste the following code into the file:
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www.)?google.com [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www.)?bing.com [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www.)?yahoo.com [NC]
RewriteCond %{HTTP_REFERER} !^http(s)?://(www.)?yourdomain.com [NC]
RewriteRule .(jpg|jpeg|png|gif)$ – [NC,F,L]
6. Save the edited .htaccess file and upload it back to the public_html folder.
Change yourdomain.com to your site’s actual domain.
Method 2: Using a CDN
Using a content delivery network (CDN) for your website has many benefits. A CDN can increase content delivery speed, providing a better performance for your visitors. It can also offer asset management features for website administrators, hotlink protection being one of them.
Here’s how to activate hotlink protection on Cloudflare:
The Scrape Shield app by Cloudflare specifically prevents image hotlinking and supports .gif, .ico, .jpg, .jpeg, and .png file types.
- Log in to your Cloudflare account and navigate to the dashboard.
- Select the Scrape Shield app, which is located on the right of the apps bar.
- Switch Hotlink Protection on.
Method 3: Using a WordPress Plugin
If you use WordPress as your website’s content management system (CMS), there are several WordPress plugins available that can prevent hotlinking. I’ll recommend just one.
My preference is the All In One WP Security and Firewall plugin, which can automatically edit your website’s .htaccess file to prevent hotlinks.
Follow these steps to set it up:
- From the WordPress dashboard, install the plugin and activate it.
- Navigate to the WP Security menu -> Firewall -> Prevent Hotlinks.
- Select Check this if you want to prevent hotlinking to images on your site.
- Click Save Settings.
In a nutShell:
Hotlinking is the act of copying assets (images, videos, or other files) by linking the file directly from other websites without authorization.
It is a bad practice that negatively impacts website owners, and server administrators. Hotlinking another website’s images or files can take up a significant amount of bandwidth on its server.
When you hotlink, You are leeching off another website owner’s resources and increasing their hosting costs.
Post Comment