Password protect a file?

Status
Not open for further replies.

Derek

Community Support Force
Community Support
Messages
12,882
Reaction score
186
Points
63
You can password protect a file but you would have to code it in..
 

dlukin

New Member
Messages
427
Reaction score
25
Points
0
If you want to password protect just one file in a directory:

1. cPanel --> Security --> Password Protect Directories

2. Password protect the directory that contains the file you want to protect.

3. Add users/passwords

4. Go to File Manager --> directory you password protected --> .htaccess

5. You should see a group of lines that look like:

Code:
AuthType Basic
AuthName "Super Secret"
AuthUserFile "/home/cPanelUserName/.htpasswds/public_html/directoryName/passwd"
require valid-user

6. Wrap the code in a FilesMatch directive, ie,

Code:
<FilesMatch "aaaa.txt">
AuthType Basic
AuthName "Super Secret"
AuthUserFile "/home/cPanelUserName/.htpasswds/public_html/directoryName/passwd"
require valid-user
</FilesMatch>

(see Apache documentation to match a group of files)

7. That should leave the rest of the directory "unprotected". You can also go back and use the cPanel to add/delete users/passwords.
 
Last edited:

lemon-tree

x10 Minion
Community Support
Messages
1,420
Reaction score
46
Points
48
Depending upon how you wish the user to interact with the login there are a variety of methods available to you:
• PHP login: This is how most registration based websites function and there are literally thousands of examples to be found through Google. This sort of system can be very extensible and allow for the interface to tailored to your needs.
• .htaccess: You can also Apache's built in methods for password protection of directories and files, which will be very quick to setup. However, this solution is far from user or administrator friendly as the interface and frequency of requests is dictated by the server and the user's browser choice.
 

williamblockland98

New Member
Messages
24
Reaction score
0
Points
0
Warning:
Due to Frontpage Extensions currently being installed and enabled, password protected directories will not work. If you wish to use this feature instead of Frontpage, please disable the Frontpage extensions.

You can use Frontpage directly to create password protected directories just like you normally can here. Alternatively, you can disable frontpage extensions and still use Frontpage to publish the site design via Webdav or FTP.

I don't know what to do
 

dlukin

New Member
Messages
427
Reaction score
25
Points
0
If you use Frontpage, you have to play by their rules. I do not know how to use Frontpage.
 
Status
Not open for further replies.
Top