Log in

View Full Version : Restrict access to directory



Schmoopy
05-09-2009, 08:21 PM
Hi, I know there are a lot of scripts that restrict access to directories and all files within them but I want one that is similar, but allows access to files within the directory, e.g:

example.com/test/randomscript.js -> Allowed

example.com/test -> Denied (Forbidden)

Here's a live example of what I mean:

http://www.headfirstmusic.co.uk/scripts/shadowbox/shadowbox-jquery.js -> Allowed

http://www.headfirstmusic.co.uk/scripts/shadowbox/ -> Denied

How can I get the same result?

Thanks.

Schmoopy
05-12-2009, 01:06 AM
Anyone?

Nile
05-12-2009, 01:13 AM
What about index.php, so:
/folder/index.php

Would that be allowed?

Schmoopy
05-12-2009, 01:45 AM
Yes, any file within the folder is allowed to be viewed. Just not as a directory view.

Nile
05-12-2009, 02:00 AM
Hmm, you could do something like:


if(substr($_SERVER['REQUEST_URI'], -9) != "index.php"){
echo "NOT OK";
}

Schmoopy
05-12-2009, 08:14 PM
True, but I'm pretty sure it's something to do with htaccess that shows it as forbidden.

theeohiostate
06-12-2009, 06:10 PM
Looking for the same answer, if you've found it


Please post

thetestingsite
06-12-2009, 08:12 PM
in an htaccess file, place the following:


Options -Indexes


Hope this helps.