Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Mar 2004
    Thanked 0 Times in 0 Posts

    Password protection on a directory

    I want to password protect a directory and it's sub directories using .htaccess, but I also have some php scripts that need to access some files inside the protected directory. The access is using something like this 'require_once('functions.php');'

    But if I password protect the directory that functions.php is in, then access is denied to my php script. I tried adding a rule to allow the server's own IP to the .htaccess, but that didn't work. Can someone suggest some ways around this problem?

  2. #2
    Senior Coder
    Join Date
    Jul 2011
    Thanked 171 Times in 171 Posts
    I'm sure there must be an easier way than this, but can you not just add username and password to your require statement?
    PHP Code:
    I'm sure that probably isn't a great way to do it, but I think it would work. No idea how safe it is to do that either, I'm guessing probably not very?

  3. Users who have thanked BluePanther for this post:

    Taipan (07-25-2011)

  4. #3
    Senior Coder Inigoesdr's Avatar
    Join Date
    Mar 2007
    Florida, USA
    Thanked 406 Times in 398 Posts
    If you are accessing it on the same server you won't need a password in your PHP script because it doesn't load the file with an HTTP request unless you explicitly ask it to with fopen wrappers(like in the previous post).


Posting Permissions

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