Page 1 of 1

.htaccess block image

Posted: Thu Mar 25, 2010 2:12 pm
by me666
hi guys.. on my host i have a folder named 'include' which holds all files needed for scripts and so on aswell as all my images in a subfolder 'img'
i have used a .htaccess file to block access from these folders/files using the following code

Code: Select all

deny from all
but now my images do not show within my pages.
i basically want to block people from viewing the files and images directly but can view them within a page.
meaning if someone typed into the address bar http://my-site.com/include/logo.jpg they wont be able to see it but on my homepage using <img src="/include/img/logo.jpg"> it will display
thanks :)

Re: .htaccess block image

Posted: Sat Jun 05, 2010 12:26 pm
by me666
hi again,
still looking for a solution on this. i have found the hotlinking to file types though.
only thing is, i get an error 500 posible bad .htaccess file message. can anyone tell me where any errors in my file may be. here is my .htaccess file

Code: Select all

<Files .htaccess>
order allow,deny
deny from all
</Files>

ErrorDocument 404 /404.html
ErrorDocument 403 /403.html

Options -Indexes

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^ http://(www.)?my-website.domain.com/.*$ [NC]
RewriteRule \.(gif|jpg|jpeg|png|JPG|JPEG|GIF|PNG)$ - [F]
thanks guys :)

Re: .htaccess block image

Posted: Mon Jul 19, 2010 3:38 pm
by wanderingSamurai
One way of doing this will be to use authentication what you can do is inside the httpd.conf file add the directory tag here's a link to the apache documentation
http://httpd.apache.org/docs/2.0/howto/auth.html