Results 1 to 8 of 8

Thread: Restrict access to directory

  1. #1
    Join Date
    Sep 2008
    Location
    Bristol - UK
    Posts
    842
    Thanks
    32
    Thanked 132 Times in 131 Posts

    Default Restrict access to directory

    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/scri...wbox-jquery.js -> Allowed

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

    How can I get the same result?

    Thanks.
    Last edited by Snookerman; 05-09-2009 at 08:48 PM. Reason: fixed link

  2. #2
    Join Date
    Sep 2008
    Location
    Bristol - UK
    Posts
    842
    Thanks
    32
    Thanked 132 Times in 131 Posts

    Default

    Anyone?

  3. #3
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    What about index.php, so:
    /folder/index.php

    Would that be allowed?
    Jeremy | jfein.net

  4. #4
    Join Date
    Sep 2008
    Location
    Bristol - UK
    Posts
    842
    Thanks
    32
    Thanked 132 Times in 131 Posts

    Default

    Yes, any file within the folder is allowed to be viewed. Just not as a directory view.

  5. #5
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Hmm, you could do something like:
    PHP Code:
    if(substr($_SERVER['REQUEST_URI'], -9) != "index.php"){
      echo 
    "NOT OK";

    Jeremy | jfein.net

  6. #6
    Join Date
    Sep 2008
    Location
    Bristol - UK
    Posts
    842
    Thanks
    32
    Thanked 132 Times in 131 Posts

    Default

    True, but I'm pretty sure it's something to do with htaccess that shows it as forbidden.

  7. #7
    Join Date
    Jun 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Looking for the same answer, if you've found it


    Please post

  8. #8
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    in an htaccess file, place the following:
    Code:
     Options -Indexes
    Hope this helps.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •