Owdy Posted June 24, 2015 Share Posted June 24, 2015 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/ / andRewriteEngine 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 More sharing options...
AutoItScript Posted June 24, 2015 Share Posted June 24, 2015 <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 More sharing options...
Owdy Posted June 24, 2015 Author Share Posted June 24, 2015 Thanks, i tested that with this tool, it doesnt work? http://www.htaccesstools.com/test-hotlink-protection/ Link to comment Share on other sites More sharing options...
AutoItScript Posted June 24, 2015 Share Posted June 24, 2015 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.htmMy 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 More sharing options...
ASTRAPI Posted June 24, 2015 Share Posted June 24, 2015 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 More sharing options...
Owdy Posted June 25, 2015 Author Share Posted June 25, 2015 I dont have Nginx. .htaccess should work, IPB htaces works fine and that redirect. Link to comment Share on other sites More sharing options...
Owdy Posted June 25, 2015 Author Share Posted June 25, 2015 Hey, that works! I forgot empty browser cache Link to comment Share on other sites More sharing options...
Owdy Posted June 26, 2015 Author Share Posted June 26, 2015 I dont get this. Sometime it works, sometimes not. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.