🇺🇸 Welcome from the USA! We have special plans for you.
View US Hosting Plans →

Block image hotlinking with .htaccess

📅 15/06/2026 ⏱ 5 min de lectura
PlatiniumHost

Escrito por

Luis Contreras · CEO & Fundador · +24 años en hosting

Block Image Hotlinking with .htaccess on your Hosting

Protect Your Bandwidth and Visual Content

In the digital age, visual content is king. But what happens when other websites use your images directly from your server, consuming your bandwidth and resources without your permission? This is known as hotlinking (or "direct linking") and can be a real headache, especially if your site receives a lot of traffic. In this article, as web hosting experts at PlatiniumHost, we will guide you through the process of blocking image hotlinking using the file .htaccess, a powerful tool for controlling your server.

What is Hotlinking?

Hotlinking occurs when another website embeds an image directly from your web server onto their own page. Instead of uploading the image to their own hosting, they simply "link" to your image's URL. This means that every time someone visits that site's page, your server is the one delivering the image, consuming your bandwidth and CPU, without them giving you credit or generating traffic to your site.

Why Block Hotlinking?

  • Bandwidth Saving: This is the most obvious benefit. If you have a hosting plan with bandwidth limits (like many of our plans at PlatiniumHost), hotlinking can cause you to reach those limits faster, which could result in additional charges or temporary suspension of your site.
  • Server Load Reduction: Each image request consumes server resources. Multiple hotlinking requests increase server load, which can slow down your own website.
  • Content Protection: Your images are yours. Blocking hotlinking helps protect your intellectual property and ensures your content is displayed in the context you intend.
  • SEO Improvement: Although indirectly, a faster site with less server load can contribute to a better user experience and, therefore, better search engine ranking.

Blocking Hotlinking with .htaccess: The Manual Solution

The file .htaccess is an Apache configuration file that allows you to override the server's default settings for a specific directory and its subdirectories. It is an incredibly useful tool for managing redirects, security, and, of course, hotlinking. For PlatiniumHost and most providers using cPanel, this method is straightforward.

Tip: Before making any changes to your .htaccess file, always create a backup. An error can cause your site to stop working.

To block hotlinking, add the following code to your .htaccess file, which is usually located in your website's root folder (public_html).

RewriteEngine On
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^https?://(www\.)?tudominio\.com [NC]
RewriteCond %{HTTP_REFERER} !^https?://(www\.)?otrodominiopermitido\.com [NC]
RewriteRule .*\.(jpg|jpeg|gif|png|bmp)$ https://tudominio.com/ruta/a/imagen-alternativa.png [R,NC,L]

Code Explanation:

  • RewriteEngine On: Activates the Apache rewrite module.
  • RewriteCond %{HTTP_REFERER} !^$: This line ensures that the request does not come from an empty referer (which could happen with some browsers or direct downloads).
  • RewriteCond %{HTTP_REFERER} !^https?://(www\.)?tudominio\.com [NC]: This is the key. It indicates that if the referer (the site requesting the image) is NOT your own domain (tudominio.com), then the following rule applies. [NC] means "No Case-sensitive".
  • RewriteCond %{HTTP_REFERER} !^https?://
🎧

¿Necesitas ayuda directa?

Soporte Nivel 3 disponible 24/7 en español.

Abrir ticket →

💬 ¿En qué podemos ayudarte?

Selecciona un agente de soporte

¿Hablamos?