LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 04-18-2007, 06:06 PM   #1
benr77
Member
 
Registered: Sep 2004
Location: London, UK
Distribution: Fedora Core 4
Posts: 59

Rep: Reputation: 15
Setup htpasswd on directory but allow access to index file


Hello there,

I need to setup htpasswd protection on a web directory served by Apache.

I also need to permit access to the index file in the specified directory, but block access to any other files or subdirectories.

So I'm using a configuration like this:

Code:
<Files index.php>
  Order deny,allow
  Allow from all
</Files>

<Directory "/home/username/www">
  AuthType Basic
  AuthName "Private Area"
  AuthUserFile /home/username/.htpasswds
  require user bill ben
</Directory>
Can anybody tell me why my override of the password protection for index.php files is being ignored?

Or alternatively tell me a better approach to password an entire web site except for the root level index file.

Any input appreciated.

Cheers

Ben
 
Old 04-18-2007, 10:27 PM   #2
djjoshuad
Member
 
Registered: Apr 2007
Location: Corinth, TX
Distribution: CentOS, RHEL, SLES, ubuntu
Posts: 44

Rep: Reputation: 15
I think the standard approach to doing this is to put all password-protected stuff into password-protected directories. I might be missing something here... but is there a reason that the index file you're talking about needs to be publicly accessible while remaining in a password-protected directory? Couldn't you just have:

/index.php
/restricted/everythingelse.php

?
 
Old 04-19-2007, 01:03 AM   #3
benr77
Member
 
Registered: Sep 2004
Location: London, UK
Distribution: Fedora Core 4
Posts: 59

Original Poster
Rep: Reputation: 15
It's an existing application that I can't change the directory structure of, so yes you are right but in this case I can't do that...
 
Old 04-19-2007, 05:35 PM   #4
benr77
Member
 
Registered: Sep 2004
Location: London, UK
Distribution: Fedora Core 4
Posts: 59

Original Poster
Rep: Reputation: 15
I've just found out that the answer to this problem is to add "Satisfy any" into the <Files> directive.

Hope this helps other people who may find this thread...
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
apache .htaccess and htpasswd - can't lock directory jordanthompson Linux - Software 9 02-07-2005 11:12 PM
how do i prevent the directory/file links from showing in the absence of index.*? spyghost Linux - Networking 2 10-08-2004 10:52 AM
Permissions, File, Directory access tHcnunz Linux - Newbie 3 03-26-2004 09:25 AM
File/directory access rights klmn1 Linux - Software 3 05-29-2003 01:14 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 03:48 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration