SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Aug 2004
    Location
    UK
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    .htaccess and php

    Hi

    I have protected my some of my website directories using .htaccess and .htpasswd files. This means that any user trying to access my protected directories need to enter a username and password.

    My question is: It seems that if I have a serverside PHP script (which is stored in the none protected area of my website) it is not able to access the protected directories. Is it possible to have a directory protected with .htaccess which still allows serverside scripts to access it?

    Many Thanks

    Estella

  2. #2
    SitePoint Enthusiast
    Join Date
    Aug 2004
    Location
    around
    Posts
    72
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    can you give more explaination? why do you want to access the directory and what do you want to do? if you use absolute paths it wont need authentication because the .htaccess is used by httpd. instead of using www.site.com/safe_dir use /home/user/htdocs/safe_dir

  3. #3
    $this->toCD-R(LP); vinyl-junkie's Avatar
    Join Date
    Dec 2003
    Location
    Federal Way, Washington (USA)
    Posts
    1,526
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I hope no one minds me butting into this thread, but I've been curious myself as to how password protection works on directories.

    Let me see if I have this straight. If a user requested a page in a password protected directory from the browser like this:
    Code:
    http://www.mydomain.com/admin/myfile.php
    the browser would put up a password screen before they could access it, right?

    On the other hand, if I included that file on a web page, specifying its full path, like this for example:
    Code:
    include('full/path/to/myfile.php');
    the page would have no problem accessing the file, even those the directory is password protected.

    Please tell me if my understanding is correct on this. Thanks.
    Music Around The World - Collecting tips, trade
    and want lists, album reviews, & more
    Showcase your music collection on the Web

  4. #4
    SitePoint Enthusiast
    Join Date
    Aug 2004
    Location
    around
    Posts
    72
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yup. you arent password protecting the directory, your password protecting access to it through httpd. using absoluting paths isnt going through httpd so the .htaccess file means nothing but if you included like this then it wouldnt work
    Code:
    include 'http://www.mydomain.com/admin/myfile.php';
    but include isnt used that way anyway


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
  •