Welcome Guest, Not a member yet? Register   Sign In
Good solution for protecting image files in folder
#21

[eluser]slowgary[/eluser]
Sorry, I missed the referrer check in your htaccess above. That method would also protect your files from hotlinking if you can get it to work right.

As far as performance goes... yes, using a controller will add overhead. It shouldn't be a whole lot, but if you're autoloading a ton of CI libraries then it could be. The benefit to using a controller is that it's not just limited to protecting images from hotlinking. It really depends on your application, but you could protect images that belong to one user from being seen by another user, or you could allow users to see images for only a certain period of time, or you could limit the number of images a user views within a given time, or if you wanted to be able to retrieve different sizes of an image such as thumbnails, or screen size, or maybe add a watermark.

If all you want to do is protect from hotlinking, the htaccess will probably be the best performer. I'm more of an htaccess "copy and paster", so I can't really help in that department. Good luck, I hope this helps.
#22

[eluser]esset[/eluser]
Yeah my knowledge of htaccess isn't far more then copy-n-paste either Smile



Any htaccess gurus who know if it's possible to combined the two "functions" above?
#23

[eluser]slowgary[/eluser]
Found this site by googling: http://altlab.com/htaccess_tutorial.html

They've got the following htaccess that gives hotlinkers an alternate image...
Code:
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?mysite\.com/ [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteRule .*\.(jpe?g|gif|bmp|png)$ /images/nohotlink.jpe [L]

Don't know about that 'jpe' extension though.
#24

[eluser]esset[/eluser]
Yeah... now try combinding this with the mod_rewrite rule to remove index.php Smile




Theme © iAndrew 2016 - Forum software by © MyBB