SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Enthusiast
    Join Date
    Oct 2002
    Posts
    64
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Can htaccess be used to limit access to 1 file?

    I have searched on google... I have searched sitepointforums... no luck. I understand that htaccess can be used to protect a whole directory with basic authentication, but all I need is one file protected.

    Can this be done and how?

    Just looking for an easier way than hacking out the Perl within the page. Well, I would also like to know for future reference, of course. Anyway, if it can't be done... I will just have to move the file to it's own directory.

  2. #2
    Making a better wheel silver trophy DR_LaRRY_PEpPeR's Avatar
    Join Date
    Jul 2001
    Location
    Missouri
    Posts
    3,428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i think it can be done with <Files>. e.g.

    Code:
    <Files file.ext>
    # Auth stuff
    </Files>
    hope that's the correct syntax. (pippo? )
    - Matt ** Ignore old signature for now... **
    Dr.BB - Highly optimized to be 2-3x faster than the "Big 3."
    "Do not enclose numeric values in quotes -- that is very non-standard and will only work on MySQL." - MattR

  3. #3
    FreeBSD The Power to Serve silver trophy pippo's Avatar
    Join Date
    Jul 2001
    Location
    Italy
    Posts
    4,514
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    >> hope that's the correct syntax
    Yes it is!!! :-))

    I only add that it will protect file.ext under subdirectories too.


    :-) pippo
    Mr Andrea
    Former Hosting Team Advisor
    Former Advisor of '03

  4. #4
    Making a better wheel silver trophy DR_LaRRY_PEpPeR's Avatar
    Join Date
    Jul 2001
    Location
    Missouri
    Posts
    3,428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by pippo
    I only add that it will protect file.ext under subdirectories too.
    oh yeah. any way to get around that without over-riding file.ext in each child directory with another .htaccess?

  5. #5
    FreeBSD The Power to Serve silver trophy pippo's Avatar
    Join Date
    Jul 2001
    Location
    Italy
    Posts
    4,514
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by DR_LaRRY_PEpPeR
    oh yeah. any way to get around that without over-riding file.ext in each child directory with another .htaccess?
    AFAIK, no.


    :-) pippo

    p.s.
    >> without over-riding file.ext in each child directory with
    >> another .htaccess?
    That's interesting,
    example:
    /file.ext <<-- is protected with the files directive you wrote
    how do you avoid that
    /subdir/file.ext is protected too ?
    Last edited by pippo; Mar 4, 2003 at 02:49.
    Mr Andrea
    Former Hosting Team Advisor
    Former Advisor of '03

  6. #6
    Making a better wheel silver trophy DR_LaRRY_PEpPeR's Avatar
    Join Date
    Jul 2001
    Location
    Missouri
    Posts
    3,428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i don't really know.

    i was thinking maybe in /subdir/

    Code:
    <Files file.ext>
    Allow from All
    </Files>
    but have no clue what that would do.

  7. #7
    FreeBSD The Power to Serve silver trophy pippo's Avatar
    Join Date
    Jul 2001
    Location
    Italy
    Posts
    4,514
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yup,
    I tried my self some variations (included the one you proposed too)
    but they didn't work.
    Once enabled it seems there is not way to disable it.

    It's something to think about... ;-)
    Mr Andrea
    Former Hosting Team Advisor
    Former Advisor of '03


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
  •