• This is my code in .htaccess
    Hotlink protection is not working for me.
    I want to show a custom image.
    What I am doing wrong? Check my code and please tell me what should I do to correct it.

    # BEGIN WordPress
    
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    
    <IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?hotmug.org [NC]
    RewriteRule \.(jpg|jpeg|png|gif)$ hotmug.org/no-hotlink.png [NC,R,L]
    </ifModule>
    
    # END WordPress
Viewing 1 replies (of 1 total)
  • Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    🏳️‍🌈 Advisor and Activist

    Deleted bump. Please don’t. Everyone’s a volunteer here, so sometimes we’re busy.

    First, put the hotlink protection ABOVE the WP lines. It should always be WP Last 🙂

    My preferred code is this:

    # ultimate hotlink protection
    <IfModule mod_rewrite.c>
     RewriteEngine on
     RewriteCond %{HTTP_REFERER}     !^$
     RewriteCond %{REQUEST_FILENAME} -f
     RewriteCond %{REQUEST_FILENAME} \.(gif|jpe?g?|png)$           [NC]
     RewriteCond %{HTTP_REFERER}     !^https?://([^.]+\.)?domain\. [NC]
     RewriteRule \.(gif|jpe?g?|png)$                             - [F,NC,L]
    </ifModule>

    However you’re trying to show a PNG, so you will have to put in an exclusion for that. Frankly, I wouldnt bother. Just break the link.

Viewing 1 replies (of 1 total)
  • The topic ‘Can't stop Image Hotlinking. Please check my code.’ is closed to new replies.