Jump to content

restrict access to images folder


vinpkl

Recommended Posts

hi all

 

i have two folders

1) images folder

2) document folder

 

at present any body can write

1) domain.com/images/logo.gif

2) domain.com/document/resume.doc

 

and access the file from the addres bar.

 

i want to restrict this access to all visitors.

i have searched on this topic and found it may be posible with .htaccess file but i dont know how to make .htaccess file and what to write in it. If there is any other way to do then also tell me.

 

vineet

Link to comment
https://forums.phpfreaks.com/topic/135280-restrict-access-to-images-folder/
Share on other sites

hi dclamp

 

i read the link that u gave me. i would like to ask that they have written these code lines

RewriteEngine on 
RewriteRule ^(.*)$ - [F] 

 

and

RewriteCond %{HTTP_REFERER}!^$ 
RewriteCond %{HTTP_REFERER}!^http://(www\.)?domain.com(/)?.*$ [NC] 
RewriteRule .*\.(gif¦jpg¦png)$ - [F] 

 

can u tell me where they are inserting these lines. they are not talking about where to put these lines, in php or where so that i can insert them and test them.

 

vineet

hi dclamp

 

i m using xampp. i have my project at

 

http://localhost/vineet/

 

i created .htaccess file and pasted this file in vineet folder. after this

when i accessed in the server

 

http://localhost/vineet/

 

i got this error

Server error!
The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there was an error in a CGI script. 

If you think this is a server error, please contact the webmaster. 

Error 500
localhost
12/03/08 10:33:54
Apache/2.2.8 (Win32) DAV/2 mod_ssl/2.2.8 OpenSSL/0.9.8g mod_autoindex_color PHP/5.2.5 

 

Its blocking the whole website to even display.

 

vineet

 

 

hi dclamp

 

if this solution doesnt work on windows. Then wil it work if i put this file on online server.

 

because online server wil always be linux for php hosting. I cannot check it at present but if its works then i can apply it in future when i take linux hosting.

 

vineet

Archived

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

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.