WordPress.org

Ready to get started?Download WordPress

Forums

HELP to Prevent Hotlinking with htaccess (8 posts)

  1. Saijo George
    Member
    Posted 6 years ago #

    I want to prevent other sites from hotlinking from my site

    .htaccess on my server is

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>

    # END WordPress

    AddType Applicaions/CAB .cab

    what i want to do is each time a hot-link is done to a (cab,zip,rar,exe ) I waant the user to land on
    http://www.1800pocketpc.com/sorry-hotlinking-has-been-disabled

    and when an image (jpg/jpeg/bmp/png/gif) is hotlinked I want this image to be shown on the other site, having this image hosted on my site might not work so itys hosted on image shack
    http://img168.imageshack.us/img168/7426/hotlinkingdisabled4117djv3.jpg

    I am not sure what I have to add in to .htaccess , This is what I have come up with ( through google ) , I am not sure if this is correct though

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>

    # END WordPress

    AddType Applicaions/CAB .cab

    RewriteEngine on
    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} !^http://(www\.)?1800pocketpc.com/.*$ [NC]
    #RewriteRule \.(gif|jpg|png|gif|bmp)$ - [F]
    #RewriteRule \.(gif|jpg|png|gif|bmp)$ http://img168.imageshack.us/img168/7426/hotlinkingdisabled4117djv3.jpg [R,L]
    #RewriteRule \.(cab|zip|rar|exe)$ - [F]
    #RewriteRule \.(cab|zip|rar|exe)$ http://www.1800pocketpc.com/sorry-hotlinking-has-been-disabled [R,L]

    can some one tell me if this is right. thanks :)

  2. whooami
    Member
    Posted 6 years ago #

    no-one needs to tell you if its right.
    http://www.htaccesstools.com/test-hotlink-protection/

  3. whooami
    Member
    Posted 6 years ago #

  4. Saijo George
    Member
    Posted 6 years ago #

    This dosent work :(

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>

    # END WordPress

    AddType Applicaions/CAB .cab

    RewriteEngine on
    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} !^http://(www\.)?1800pocketpc.com/.*$ [NC]
    RewriteRule \.(gif|jpg|png|gif|bmp)$ - [F]
    RewriteRule \.(gif|jpg|png|gif|bmp)$ http://img168.imageshack.us/img168/7426/hotlinkingdisabled4117djv3.jpg [R,L]
    RewriteRule \.(cab|zip|rar|exe)$ - [F]
    RewriteRule \.(cab|zip|rar|exe)$ http://www.1800pocketpc.com/sorry-hotlinking-has-been-disabled [R,L]

  5. Saijo George
    Member
    Posted 6 years ago #

    any ideas whats wrong with .htaccess posted above ?

  6. Roy
    Member
    Posted 6 years ago #

    No, but this plugin does the trick for me and the newer versions of Ask Apache have the option too.

  7. Saijo George
    Member
    Posted 6 years ago #

    thanks Gangleri,
    now to get hot-link done to a (cab,zip,rar,exe ) I want the user to land on
    http://www.1800pocketpc.com/sorry-hotlinking-has-been-disabled

    any tip for that, anyone :)

  8. askapache
    Member
    Posted 6 years ago #

    Try this :)

    RewriteEngine On
    RewriteBase /
    RewriteCond %{HTTP_REFERER} !^http://(www\.)?1800pocketpc\.com [NC]
    RewriteCond %{HTTP_REFERER} !^$
    RewriteRule \.(cab|zip|rar|exe) http://www.1800pocketpc.com/sorry-hotlinking-has-been-disabled [R,L]
    
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    
    # END WordPress

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.