Apache Prevent Hotlinking Linux PMC Tactical

Welcome to Apache Prevent Hotlinking Linux PMC Tactical.

Website hosting and domain registration fees are due, please Support PMC, thank you. You can read more details from PMC Website Hosting and Domain Registration Fee Status forum topic.

Apache Prevent Hotlinking

Apache Prevent / Block Image / File Hotlinking

Create a .htaccess file under the document root of your website. Then add the following rules to the created .htaccess file. This will block all domains except example.com to hotlink images from your site.

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^https?://(.+\.)?example.com [NC]
RewriteRule \.(jpg|png)$ - [NC,F,L]

You can also show a blocked banner in place of the hot-linked image. To show the banner use below rules in your .htaccess file.

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^https?://(.+\.)?example.com [NC]
RewriteRule \.(jpg|png) http://example.com/blocked.png [R,L]