amy
9/26/2019 - 6:23 AM

HTAccess Prevent Hotlinking of Images


# BEGIN Prevent Hotlinking of images
<IfModule mod_rewrite.c>
 RewriteEngine on
 RewriteCond %{HTTP_REFERER}     !^$
 RewriteCond %{REQUEST_FILENAME} -f
 RewriteCond %{REQUEST_FILENAME} \.(gif|jpe?g?|png|ico)$           [NC]
 RewriteCond %{HTTP_REFERER}     !^https?://([^.]+\.)?yourwebsite\. [NC]
 RewriteRule \.(gif|jpe?g?|png|ico)$                             - [F,NC,L]
</ifModule>
# END Prevent Hotlinking of images


------------------ OR --------------------------


# Prevent Hotlinking of images
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?yourwebsite.com [NC]
RewriteRule \.(jpg|jpeg|png|gif)$ - [NC,F,L]