Jump to content

Hotlinking


Recommended Posts

Posted

I wanna disable hotlinking via htaccess, but i dont know how to merge that to IPB htaccess file. So how do i merge these 2?

<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule \.(js|css|jpeg|jpg|gif|png|ico)(\?|$) - [L,NC,R=404]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Redirect 301 /foorumi/ /

and

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?hoitajat.net [NC]
RewriteRule \.(jpg|jpeg|png|gif)$ http:/someimageurlsfsdf.com/somefile.jpg [NC,R,L]

 

Posted
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?hoitajat.net [NC]
RewriteRule \.(jpg|jpeg|png|gif)$ http:/someimageurlsfsdf.com/somefile.jpg [NC,R,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule \.(js|css|jpeg|jpg|gif|png|ico)(\?|$) - [L,NC,R=404]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Redirect 301 /foorumi/ /

 

Posted

Doesn't work for me either (though it used to). I recently switched to nginx, looks like your server is nginx too. If nginx is serving static files (.png etc) and not handing it over to apache, then you have to disable hotlinking in the nginx config instead.

http://download1.parallels.com/Plesk/Doc/en-US/online/plesk-administrator-guide/index.htm?fileName=71997.htm

My server is using the top configuration, so it makes sense. You'll be in a similar situation I imagine.

Posted

Remember that Nginx doesn't support/read htaccess :)

So for hotlinking in Nginx:


Use a location directive inside your Nginx configuration file:


 

location ~ .(gif|png|jpe?g)$ {
     valid_referers none blocked mywebsite.com *.mywebsite.com;
     if ($invalid_referer) {
        return   403;
    }
}


The first line shows the protected file extensions, if you have other extensions to add, just add a new pipe (“|”) with the new extension you want to protect.

valid_referers line contains the list of sites allowed to hotlink images, yours must be specified there, but if you have other websites you can allow them there.


You can also protect files from a specific directory. For example:


 

location /pictures/ {
     valid_referers none blocked mywebsite.com *.mywebsite.com;
     if ($invalid_referer) {
        return   403;
    }
}


All done, now you know how to protect your website and directories from image hotlinking :)

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...