Forum Moderators: phranque

Message Too Old, No Replies

How to deny users access to a certain directory?

         

keeking

6:32 am on Jun 5, 2010 (gmt 0)

10+ Year Member



Hi, I'm looking for a way to deny users access to a certain directory.
eg. I uploaded some stuff to a directory: http://www.example.com/stuff/
now I want people to download stuff through hyperlink such as http://www.example.com/stuff/stuff1.
but I don't want people visit that directory directly. I tried to creat a .htaccess file and write "deny from all¡± in it, it indeed denied people to access, but people couldn't download from that dirctory either...
Any help would be appreciate.

[edited by: engine at 9:46 am (utc) on Jun 5, 2010]
[edit reason] examplified [/edit]

g1smd

6:37 am on Jun 5, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



One solution is to set a cookie for authentication and only allow access if the cookie has been previously set.

As you found out, the DENY directive denies everything.

tangor

8:51 am on Jun 5, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Not sure how secure you'd want it, but I'd use .htaccess and password. And possibly autogen the password and update htaccess for that subdirectory then send the password to the specific user.

keeking

8:39 am on Jun 6, 2010 (gmt 0)

10+ Year Member



I'm totally doesn't know about how to set cookie, but thank you guys!

g1smd

4:33 pm on Jun 6, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



There's tens of thousands of code examples in this and other sites.