Skip to content

Instantly share code, notes, and snippets.

@awakekat
Created September 17, 2017 15:09
Show Gist options
  • Save awakekat/a699d565b646f47a9297e2b2b2832632 to your computer and use it in GitHub Desktop.
Save awakekat/a699d565b646f47a9297e2b2b2832632 to your computer and use it in GitHub Desktop.

Revisions

  1. awakekat created this gist Sep 17, 2017.
    22 changes: 22 additions & 0 deletions stophotlink.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    # in htaccess
    # METHOD 1
    # CHANGE example.com to you domain
    # Can add other file types
    <IfModule mod_rewrite.c>
    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} !^http(s)?://([^.]+\.)?example\
    .com [NC]
    RewriteRule \.(gif|jpe?g?|png)$ - [NC,F,L]
    </IfModule>

    # in htaccess
    # METHOD 2 with replace img
    # CHANGE example.com to you domain
    # Can add other file types
    <IfModule mod_rewrite.c>
    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} !^http(s)?://([^.]+\.)?example\
    .com [NC]
    RewriteCond %{REQUEST_FILENAME} !hotlink.gif [NC]
    RewriteRule \.(gif|jpe?g?|png)$ /hotlink.gif [NC,R,L]
    </IfModule>