Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    Senior Coder doubledee's Avatar
    Join Date
    Mar 2011
    Location
    Arizona
    Posts
    1,108
    Thanks
    27
    Thanked 0 Times in 0 Posts

    Using .htaccess to protect file

    Is there a way to use .htaccess so that people cannot access a file in a directory BUT a PHP script in another directory can Include the file?

    (I have a sensitive file that I wanted to put outside of httpdocs and then Include, but the way my VPS is set up, it much harder than anticipated. So maybe using .htaccess is a reasonable workaround?!)



    Debbie

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,861
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    Is there a way to use .htaccess so that people cannot access a file in a directory BUT a PHP script in another directory can Include the file?
    Yes, you could do it.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    Senior Coder doubledee's Avatar
    Join Date
    Mar 2011
    Location
    Arizona
    Posts
    1,108
    Thanks
    27
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by abduraooft View Post
    Yes, you could do it.
    What is the syntax?

    How secure it that?

    I wanted to put my config file outside of httpdocs, but apparently the way my VPS is configured, it requires some Linux trickery that I don't think I'm up to.


    Debbie

  • #4
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,647
    Thanks
    2
    Thanked 406 Times in 398 Posts
    Code:
    deny from all

  • #5
    Senior Coder doubledee's Avatar
    Join Date
    Mar 2011
    Location
    Arizona
    Posts
    1,108
    Thanks
    27
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Inigoesdr View Post
    Code:
    deny from all
    Just that one line of code?!


    Debbie

  • #6
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,647
    Thanks
    2
    Thanked 406 Times in 398 Posts
    Nope, I withheld all of the important stuff.

    Seriously, just make a directory and try it.

  • #7
    Senior Coder doubledee's Avatar
    Join Date
    Mar 2011
    Location
    Arizona
    Posts
    1,108
    Thanks
    27
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Inigoesdr View Post
    Nope, I withheld all of the important stuff.

    Seriously, just make a directory and try it.
    Ha ha!

    It just seemed too simple.


    Debbie

    P.S. BTW, when I include my config file, is it okay to use an absolute path like...

    PHP Code:
    // Include Authorize.net Values.
    require_once('/var/www/vhosts/MyWebsite.com/httpdocs/private/auth_config.php'); 

  • #8
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,647
    Thanks
    2
    Thanked 406 Times in 398 Posts
    Quote Originally Posted by doubledee View Post
    P.S. BTW, when I include my config file, is it okay to use an absolute path like...
    That should be fine, but if it's not working check the error log. It will tell you the reason it didn't work(wrong path, permissions, open_basedir restriction, etc.).


  •  

    Posting Permissions

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