CodeIgniter Forums
Good solution for protecting image files in folder - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Good solution for protecting image files in folder (/showthread.php?tid=27583)

Pages: 1 2 3


Good solution for protecting image files in folder - El Forum - 02-15-2010

[eluser]esset[/eluser]
So let's say I have a folder in my server-root called /images/.

Now I want to protect all images in this folder (and subfolder) from direct access (like www.mydomain.com/images/001/image.jpg).

But I still want my server and/or PHP files to be able to access this folder (and subfolders/images).


Anyone got a good solution for this?

Thanks Smile


Good solution for protecting image files in folder - El Forum - 02-15-2010

[eluser]Sbioko[/eluser]
Use .htaccess.


Good solution for protecting image files in folder - El Forum - 02-15-2010

[eluser]laytone[/eluser]
create a file in /images called .htaccess
add the line:
Code:
Options -Indexes



Good solution for protecting image files in folder - El Forum - 02-15-2010

[eluser]esset[/eluser]
Will disabling "not allowing peaking into folder with no index" not prevent my regular site from accessing the files to?

Sbioko: What should that .htaccess file contain?


Thanks


Good solution for protecting image files in folder - El Forum - 02-15-2010

[eluser]esset[/eluser]
[quote author="laytone" date="1266285181"]create a file in /images called .htaccess
add the line:
Code:
Options -Indexes
[/quote]

I tried this but it didn't work, I can still access images in /images/ straight away.

Can my .htaccess in site-root conflict?

This is my .htaccess in root:

Quote:RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]




Thanks


Good solution for protecting image files in folder - El Forum - 02-15-2010

[eluser]laytone[/eluser]
Try adding that line to your root .htaccess and see if it works...


Good solution for protecting image files in folder - El Forum - 02-15-2010

[eluser]esset[/eluser]
Sorry no change.


Should I use something like "deny from all"?


Good solution for protecting image files in folder - El Forum - 02-15-2010

[eluser]laytone[/eluser]
Try this solutions:
http://www.thesitewizard.com/archive/bandwidththeft.shtml


Good solution for protecting image files in folder - El Forum - 02-15-2010

[eluser]laytone[/eluser]
I feel stupid for not thinking of this earlier. you could just Create a blank index.html file and put it in your images folder...


Good solution for protecting image files in folder - El Forum - 02-15-2010

[eluser]esset[/eluser]
[quote author="laytone" date="1266288014"]I feel stupid for not thinking of this earlier. you could just Create a blank index.html file and put it in your images folder...[/quote]

That wont protect me from people direct-linking the images though, right?


http://www.thesitewizard.com/archive/bandwidththeft.shtml didn't work, the images still render in /images/. I wonder if it somehow conflicts with the mod_rewrite rule?

I guess I could do http://www.thesitewizard.com/archive/protectimages.shtml, but I would like not to edit all the places I have linked to these images on the site Smile



Thanks for helping out