Seo is Dead

  • Seo is Dead
  • SEO Beginners
  • SEO Intermediate
  • SEO Advance
  • Black Hat
  • Link Building
  • Security
  • WordPress
  • Ecommerce
  • Monetize
Home » Blog » How to Avoid HOTLINKING?

by seoisdead Leave a Comment

How to Avoid HOTLINKING?

In this tutorial I tell you How to avoid Hotlinking your images and files, so that others do not take advantage of your resources and transfer rate.

What is Hotlinking?

All the images we show on our website have their own particular URL. These URLs appear in the HTML code when you display them on your website like this:

<img src=”http://web.com/images/cats.jpg”>

Well, if anyone else uses that same code on another website, the image will look the same. That is, anyone can display images from your website on theirs, without even having to copy it and upload it to their website. This can be very harmful, because every time that image is uploaded it is using resources and transfer rate of your server. In other words, apart from copying you, they are using your resources.

How can we avoid hotlinking?

Well, like so many things in this world, there are many ways. Some easier (but not so good), some more complex (but better).

Let’s start with the simple method, for those who don’t want to use code, because there is a WordPress plugin that solves the issue quickly. It’s called Hotlink Protection, and it does just that. It makes sure that images from your website cannot be used outside of your domain. It is the simplest plugin, and requires no configuration.
But I recommend not to put too many plugins to our WordPress. We can save these plugins and protect ourselves from hotlinking with code.
Now I show you how.

How to Avoid HOTLINKING

Avoiding Hotlinking by Code

Let’s solve all this with a few lines of code in the .htaccess file. Here they are:

Keep Reading this POST:  Data Protection on Websites

RewriteEngine on

RewriteCond %{HTTP_REFERER} !^$

RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?tu-web.com [NC]

RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?google.com [NC]

RewriteRule \.(jpg|jpeg|png|gif)$ http://tu-web.com/ alternative-image.png [NC,R,L]

Want to know what each line does? Take note

  • The first line activates the redirection engine.
  • The second line allows direct visitors to the image to see it.
  • The third line allows your own website (your-web.com) to display the images. Here everyone has to put their own domain.
  • The fourth line allows access to Google, so that it can index them all.
  • The fifth line indicates which image to show instead of the image they want to catch us.

Have you seen how it is not so complicated to work with a few lines of code? Let’s remember that we have to put this in our .htaccess file, at the end of everything. It is very important that you copy those lines without modifying anything but the URL, because a small change in the .htacces file will generate a 500 error with a white screen.
Avoiding hotlinking is a good recommendation, but we should always take precautions not to restrict it too much, as we could be losing positioning or presence in social networks.
On the other hand, in this tutorial we have talked about images, but all this is applicable to any other type of file, such as PDFs, video files, audio files (music, podcasts, recordings, etc.).

Related posts:

Data Protection on Websites

Filed Under: Security

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Blog

About

Privacity Polity

Cookie Policy

Site Map

    Copyright © 2023

    We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept”, you consent to the use of ALL the cookies.
    Cookie settingsACCEPT
    Manage consent

    Privacy Overview

    This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
    Necessary
    Always Enabled
    Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
    CookieDurationDescription
    cookielawinfo-checbox-analytics11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
    cookielawinfo-checbox-functional11 monthsThe cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
    cookielawinfo-checbox-others11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
    cookielawinfo-checkbox-necessary11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
    cookielawinfo-checkbox-performance11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
    viewed_cookie_policy11 monthsThe cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.
    Functional
    Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
    Performance
    Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
    Analytics
    Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
    Advertisement
    Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.
    Others
    Other uncategorized cookies are those that are being analyzed and have not been classified into a category as yet.
    SAVE & ACCEPT