<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>Drupal on D. Sébastien Taggart</title>
    <link>https://www.sebastientaggart.com/categories/drupal/</link>
    <description>Recent content in Drupal on D. Sébastien Taggart</description>
    <generator>Hugo</generator>
    <language>en</language>
    <lastBuildDate>Sun, 04 Oct 2026 22:13:05 -0400</lastBuildDate>
    <atom:link href="https://www.sebastientaggart.com/categories/drupal/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>The Best Way to Block Image Hotlinking</title>
      <link>https://www.sebastientaggart.com/writing/best-way-to-block-image-hotlinking/</link>
      <pubDate>Tue, 11 Sep 2018 12:20:40 -0500</pubDate>
      <guid>https://www.sebastientaggart.com/writing/best-way-to-block-image-hotlinking/</guid>
      <description>&lt;p&gt;Image hotlinking isn’t just an inconvenience; it’s a silent siphon on your resources and a potential doorway to vulnerabilities. At its core, hotlinking occurs when another website embeds an image directly from your server without your consent. This practice can inflate your bandwidth costs and expose your site to security risks.&lt;/p&gt;
&lt;p&gt;So, how do we effectively curb this practice? If you&amp;rsquo;re using Drupal, a few straightforward lines in your &lt;code&gt;sites/all/files/.htaccess&lt;/code&gt; file can make a significant difference. Let&amp;rsquo;s walk through a practical approach to securing your images:&lt;/p&gt;</description>
      <content:encoded><![CDATA[<p>Image hotlinking isn’t just an inconvenience; it’s a silent siphon on your resources and a potential doorway to vulnerabilities. At its core, hotlinking occurs when another website embeds an image directly from your server without your consent. This practice can inflate your bandwidth costs and expose your site to security risks.</p>
<p>So, how do we effectively curb this practice? If you&rsquo;re using Drupal, a few straightforward lines in your <code>sites/all/files/.htaccess</code> file can make a significant difference. Let&rsquo;s walk through a practical approach to securing your images:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-apache" data-lang="apache"><span class="line"><span class="cl"><span class="c"># Image hotlink protection</span>
</span></span><span class="line"><span class="cl"><span class="nt">&lt;IfModule</span> <span class="s">mod_rewrite.c</span><span class="nt">&gt;</span>
</span></span><span class="line"><span class="cl"> <span class="nb">RewriteEngine</span> <span class="k">on</span>
</span></span><span class="line"><span class="cl"> <span class="nb">RewriteCond</span> %{HTTP_REFERER}     !^$
</span></span><span class="line"><span class="cl"> <span class="nb">RewriteCond</span> %{REQUEST_FILENAME} -f
</span></span><span class="line"><span class="cl"> <span class="nb">RewriteCond</span> %{REQUEST_FILENAME} \.(gif|jpe?g?|png)$           [NC]
</span></span><span class="line"><span class="cl"> <span class="nb">RewriteCond</span> %{HTTP_REFERER}     !^https?://([^.]+\.)?yourdomain\. [NC]
</span></span><span class="line"><span class="cl"> <span class="nb">RewriteRule</span> \.(gif|jpe?g?|png)$                             - [F,NC,L]
</span></span><span class="line"><span class="cl"><span class="nt">&lt;/IfModule&gt;</span>
</span></span></code></pre></div><p>Now, let’s break this down for clarity:</p>
<ol>
<li>
<p><strong>RewriteEngine on</strong>: This enables the rewrite engine, setting the stage for the rules that will follow.</p>
</li>
<li>
<p><strong>RewriteCond %{HTTP_REFERER} !^$</strong>: This condition checks if the referrer is empty, which indicates a direct request. We want to allow such requests.</p>
</li>
<li>
<p><strong>RewriteCond %{REQUEST_FILENAME} -f</strong>: Here, we’re ensuring that the request is for a valid file. If it isn’t, our rules don’t need to apply.</p>
</li>
<li>
<p><strong>RewriteCond %{REQUEST_FILENAME} .(gif|jpe?g?|png)$ [NC]</strong>: We specify the file types we wish to protect, and the <code>NC</code> flag makes this condition case-insensitive.</p>
</li>
<li>
<p><strong>RewriteCond %{HTTP_REFERER} !^https?://([^.]+.)?yourdomain. [NC]</strong>: This condition checks that the referrer is not from your own domain (just replace <code>yourdomain</code> with your actual domain). If it isn’t, we’ll block the request.</p>
</li>
<li>
<p><strong>RewriteRule .(gif|jpe?g?|png)$ - [F,NC,L]</strong>: Finally, this rule denies access to the specified file types from all other referrers, returning a 403 Forbidden response.</p>
</li>
</ol>
<p>By applying this solution, you can protect your digital resources from unauthorized usage while maintaining control over your content.</p>
<p>In a landscape where digital assets are easily shared and repurposed, safeguarding your work isn’t just smart—it’s essential. It’s about ensuring that your efforts are acknowledged and that your resources are used judiciously.</p>
<p>As you implement these changes, I encourage you to keep a curious eye on your server logs. They can provide valuable insights into how your content is accessed, potentially revealing unexpected patterns that may warrant further exploration.</p>
<p>Take action today, and reclaim your bandwidth!</p>
]]></content:encoded>
    </item>
  </channel>
</rss>
