Please wait while we load your page...
 

Announcements

HTACCESS Magic :: Article :: Password Protect a Single File





Results 1 to of

Password Protect a Single File

Normally, you would password protect a directory, and by adding a .htaccess file to the directory as follows:

AuthName "Restricted Area"
AuthType Basic
AuthUserFile /full/path/to/password/file/.htpasswd
require valid-user


To password protect just a single file (in this example, admin.php), modify as follows:

AuthName "Restricted Area"
AuthType Basic
AuthUserFile /full/path/to/password/file/.htpasswd
<Files "admin.php">
require valid-user
</Files>


One is only prompted to authenticate if they call the admin.php file, but not any other file in the same directory.

Last Revised: 2015-07-17

Live Chat Not Available