Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using htaccess, how to restrict seeing directory contents, but allow server to use the contents?

Tags:

php

.htaccess

More specifically, I have an htaccess file that restricts anyone from seeing the directory contents. Such that, nobody can see my 1000s of images in www.example.com/images by using:

deny from all allow from 127.0.0.1 

However, I want to use these images on www.example.com such that, <img src="images/thisimg.jpg" /> works.

I hope I'm in the right direction, but I appreciate any insight/re-direct. This is similar to: How to protect all directory contents, but gain access to php script but I want to link to these images in that directory, and using deny from all does not allow me to do that.

Thanks in advance for your help.

like image 208
Josh Avatar asked May 27 '11 20:05

Josh


People also ask

Does htaccess work on subdirectories?

htaccess file are applied to the directory in which the . htaccess file is found, and to all subdirectories thereof. However, it is important to also remember that there may have been . htaccess files in directories higher up.


1 Answers

in .htaccess

Options -Indexes 

http://httpd.apache.org/docs/current/mod/core.html#options

like image 152
Magicianeer Avatar answered Oct 07 '22 17:10

Magicianeer