• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 193
  • Last Modified:

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?
0
zattz
Asked:
zattz
  • 2
2 Solutions
 
ncooCommented:
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
 
ncooCommented:
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

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now