apache apply authentication to one file

Hi

If I had a virtualhost such as
<Directory "/var/www/html/John">
AuthType Basic
AuthName "Restricted Files"
AuthUserFile /etc/httpd/conf/access
Require user John
</directory>

and I wanted to apply the authentication to only one called index.php, how would I do that?
zattzAsked:
Who is Participating?
 
ncooConnect With a Mentor Commented:
In the folder of the file you want to secure add the following ".htaccess" file
<Files filename.html>
    AuthType Basic
    AuthName "Protected Access"
    AuthUserFile /path/to/passwd
    Require valid-user
</Files>

Open in new window

0
 
ncooConnect With a Mentor Commented:
Using your data it should be something like:
<Files index.php>
    AuthType Basic
    AuthName "Restricted Files"
AuthUserFile /etc/httpd/conf/access
Require user John
</Files>

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.