Do you want to password protect a directory on your website?
Lets suppose you want to protect the folder ‘secretfolder’ located on this path on your server: home/user/domain/secretfolder
Password Protect Directory with htaccess
Step 1 – Create .htpasswd file with your desired username and password in any text editor (like Notepad) and save.
within the .htpasswd you will have the following info
abc:9476nIHW7Esgw
encrypt you password through some tool and put that here with username you can that from from here
http://www.4webhelp.net/us/password.php
Step 2 – Create .htaccess file with the code below. It can be created using any text editor (like Notepad) and saved without the .txt extension.
vim .htaccess
AuthUserFile /home/user/domain/secretfolder/.htpasswd # please the location of .htpasswd file should be known to you. if not don't wast your time.
AuthType Basic
AuthName "Login Details"
Require valid-user
Step 3 – Upload both these files in the same folder which you want to protect
Now whenever anyone accesses that directory or any files in it, they will be asked for login details. You web directory is now secure.
That's it
Enjoy your Security at layer 1.
Regards:
imran
skype: shahmeer07
No comments:
Post a Comment