Jump to content

Hotlinking


Recommended Posts

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]

 

Link to comment
Share on other sites

<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/ /

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 :)

Link to comment
Share on other sites

Archived

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

  • Recently Browsing   0 members

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