SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Wizard holmescreek's Avatar
    Join Date
    Mar 2001
    Location
    Northwest Florida
    Posts
    1,707
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PHP includes with htaccess protected dirs

    Quick question here. If I have a php script in my document root can it include another php file that is located in a .htaccess protected directory without the system tossing up a user name / password dialog box?


    Thanks in advance!

  2. #2
    Serial Publisher silver trophy aspen's Avatar
    Join Date
    Aug 1999
    Location
    East Lansing, MI USA
    Posts
    12,937
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    .htaccess is for remotely accessing your website.

    That include will be being accessed by your webserver itself, not the person at the other end of the browser, so you shouldn't have any problems.
    Chris Beasley - I publish content and ecommerce sites.
    Featured Article: Free Comprehensive SEO Guide
    My Guide to Building a Successful Website
    My Blog|My Webmaster Forums

  3. #3
    SitePoint Wizard holmescreek's Avatar
    Join Date
    Mar 2001
    Location
    Northwest Florida
    Posts
    1,707
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks aspen. (I'll post my intentions here and maybe it will help someone else reading this thread).

    One of the problems I'm having is that I develop under Win2K with Apache. After reading Kev's article a while back I just stick all my include files in /phplib just in case (as he suggests) one has a mysql password and PHP happens to fail disclosing this information.

    I created a include file called paths.php that I "toggle" a path variable for my scripts depending on if I'm developing on the local server or if the scripts are uploaded to a hosting servce.

    -- paths.php
    // for local host
    $PHPLIBPATH = "/apache/phplib/";

    // for hosting service
    $PHPLIBPATH = "/home/mydomain/phplib";

    ----
    my other scripts in the document root would have something like this in them :

    include("paths.php");
    include($PHPLIB . "dbaccess.php");

    ----------------

    I think it just much easier to have something like this in the php files in the document root :

    include("protecteddir/dbaccess.php");

    where as protecteddir is .htaccess password protected.
    -----


    Any suggestions on "avoiding" the use of absolute server paths at all is appreciated. It just saves time when I get ready to upload my scripts to a hosting service where as I don't have to go back in and change the paths.php file every time.


    Thanks again!


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
  •