|
Home > Archive > Apache Server configuration support > December 2005 > using htaccess to protect one file
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
using htaccess to protect one file
|
|
| aixenv@yahoo.com 2005-12-27, 6:10 pm |
| im trying to find some information on how to use .htaccess and the
files directive to protect one file? i posted to another usenet group
but after looking at the posting im thinking it's rarely if ever viewed
anymore.
i have a specific php file = admin.php and im trying to make it so it's
p/w protected via htaccess, NOTE: there are other files in this
directory that i want to be accessible just as it always was, i've done
many a p/w protected dir in apache, but i have never used htaccess to
block access to a specific file while leaving all the other files in
that same dir accessible.
my htaccess looks like this
<Files "admin.php">
AuthType Basic
AuthName "Restricted Files"
AuthUserFile /etc/httpd/htpasswd
Require valid-user
</Files>
the perms on both htpasswd and .htaccess are 644 with root:root however
the directory that has this admin.php file just gives a 403 permission
denied, not sure what im doing wrong, the only reference i found to
someone trying to do this, was basically like i have tried to
accomplish it, any help is appreciated. thank you
| |
|
|
| Purl Gurl 2005-12-27, 8:55 pm |
| aixenv wrote:
Topic: protect a single file via authentication
> my htaccess looks like this
> <Files "admin.php">
> AuthType Basic
> AuthName "Restricted Files"
> AuthUserFile /etc/httpd/htpasswd
> Require valid-user
> </Files>
Your syntax is correct. Use a full path for AuthUserFile.
> the perms on both htpasswd and .htaccess are 644 with root:root however
> the directory that has this admin.php file just gives a 403 permission denied
Your 403 appears unrelated to your authentication. Might be your directory is outside
your document root and needs to be aliased. Might be permission is denied for your
directory in your httpd configuration file.
Test access without your .htaccess file. Then test with your .htaccess file.
Purl Gurl
|
|
|
|
|