Files Protect

Fix it!!

Files Protect

Postby BeckhamStZ » Mon Sep 04, 2006 9:20 am

I want to protect my image files from direct access but i don't know how ... i want to access files only from php script. can anyone help me ?
BeckhamStZ
 
Posts: 4
Joined: Mon Sep 04, 2006 9:08 am

Postby richardk » Mon Sep 04, 2006 11:12 am

Use mod_access, in a .htaccess file in the images directory:
Code: Select all
Order Deny,Allow
Deny from all


If the images arn't in their own directory:
Code: Select all
<FilesMatch "\.(gif|jpe?g|png|bmp)$">
  Order Deny,Allow
  Deny from all
</FilesMatch>
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby BeckhamStZ » Mon Sep 04, 2006 12:32 pm

Ok but after that how i can access the pictures from php script !?
BeckhamStZ
 
Posts: 4
Joined: Mon Sep 04, 2006 9:08 am

Postby richardk » Mon Sep 04, 2006 2:09 pm

You're trying to have a script that loads the image, right? Eg. loadImage?image=imagenam.png Then you'd use readfile() or file_get_contents().

If you're looking for hotlink protection:
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{HTTP_REFERER} .
RewriteCond %{HTTP_REFERER} !^http://(www\.)?you-domain\.com(/.*)?$ [NC]
RewriteRule \.(gif|jpe?g|bmp|png)$ - [F,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby BeckhamStZ » Mon Sep 04, 2006 11:17 pm

in my index.php file when i open from browser it doesn't show pictures ... but when write adress on picture it's open ... and i don't want to open direct ...
BeckhamStZ
 
Posts: 4
Joined: Mon Sep 04, 2006 9:08 am

Postby richardk » Tue Sep 05, 2006 5:31 am

Please explain what you are trying to do.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby BeckhamStZ » Tue Sep 05, 2006 7:38 am

i was do.. thank you for code... :D
BeckhamStZ
 
Posts: 4
Joined: Mon Sep 04, 2006 9:08 am


Return to Security with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 14 guests

cron