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

[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
#2

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

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

[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
#5

[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
#6

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

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


Should I use something like "deny from all"?
#8

[eluser]laytone[/eluser]
Try this solutions:
http://www.thesitewizard.com/archive/ban...heft.shtml
#9

[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...
#10

[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/ban...heft.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/pro...ages.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




Theme © iAndrew 2016 - Forum software by © MyBB