#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    9
    Rep Power
    0

    Accessing website root directory


    Hi guys, just a quick question.

    I am developing a website at the moment and just wondered whether or not it was possible to access a folders root directory/files from the browser directly.

    And if there is, no i dont want it, thats not what im after.

    I have a password protected area that is monitored by using session variables, however the files have no protection.

    The only method i can think of at the moment is just including an index.php file in each of the folders that displays a forbidden message.

    Should i be password protecting these folders and is that even possible?

    Cheers
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    9
    Rep Power
    0
    ok so i just seen that i cant access the root directory when it is hosted due to restrictions, its only on my localhost I can.
    But if someone finds out the direct url of the file they could still access it, how can i stop this?
  4. #3
  5. Code Monkey V. 0.9
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Mar 2005
    Location
    A Land Down Under
    Posts
    2,136
    Rep Power
    1990
    The two easiest ways are:

    1. Store your files outside of the web root, and use a script to transfer them to the users when they are authorised to view/download them.

    2. Set up a .htaccess file that blocks all access to that directory.

    There's tutorials for both of those around the net that you can find without any effort at all, so have a look and see what you can do.
  6. #4
  7. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,316
    Rep Power
    7171
    This question needs added to the faq
    PHP FAQ

    Originally Posted by Spad
    Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around
  8. #5
  9. CSS & JS/DOM Adept
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jul 2004
    Location
    USA (verifiably)
    Posts
    20,131
    Rep Power
    4304
    Originally Posted by E-Oreo
    This question needs added to the faq
    Yeah, this is a good candidate for a FAQ. Which FAQ do you mean?
    Spreading knowledge, one newbie at a time.

    Check out my blog. | Learn CSS. | PHP includes | X/HTML Validator | CSS validator | Common CSS Mistakes | Common JS Mistakes

    Remember people spend most of their time on other people's sites (so don't violate web design conventions).
  10. #6
  11. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,316
    Rep Power
    7171
    I was thinking of the PHP FAQ actually, specifically for this question:
    Store your files outside of the web root, and use a script to transfer them to the users when they are authorised to view/download them
    That question seems to come up pretty frequently.
    PHP FAQ

    Originally Posted by Spad
    Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    9
    Rep Power
    0
    Thanks alot peeps, i'll look into it.

    Apologies for not finding a thread with the answer on beforehand
  14. #8
  15. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,316
    Rep Power
    7171
    I meant actually that I should write one, didn't mean to imply that you should have found one. Hopefully I'll get around to it by the time it's still useful to you.
    PHP FAQ

    Originally Posted by Spad
    Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around
  16. #9
  17. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    14
    Rep Power
    0

    root


    I think there is no solution to this one. Everybody is wasting time.

    Comments on this post

    • Catacaustic disagrees : I gave two solutions above, and others have given solutions too. How is there "no solution"???

IMN logo majestic logo threadwatch logo seochat tools logo