Put in .htaccess file in the directory you are trying to protect:
AuthType Basic AuthName "This Area is Password Protected" AuthUserFile /full/path/to/.htpasswd Require valid-user
Ideally, the .htpasswd file will be not in a public facing directory. Put this in there:
That is just a sample, you can create the code for your unique username and password here.
Note that all subdirectories of this directory will also be password protected by this same system.
Yup, very good to mention that .htpasswd should NOT be in the same directory as the directory you’re trying to protect or any other location within something alike “public_html”.
I usually put .htpasswd files in domain- or home-folders.
I am really very thanks for this information
how do you create a file such as .htaccess?
If you’re trying to create it on Windows you can simply do it with Notepad. Just launch it, paste the code and then save with the name
.htaccess(make sure “All Files” is selected in the type field). That’s it.
@Tyler: You can create a blank text file file called .htaccess in the root directory of your site and then just paste the code in.
hello sir i set these on my domain home directory which is a wordpress hosted website the after editing .htaccess file the it show internal server error now how i do this
I get a message that says the password will be sent unencrypted, is there a way to send it encrypted via
What is the password encoded as?
TnQ for ur fantastic trick it’s usefull but i have a question
how can i set this to let dl files without authentication
for example when i request this http://site.com/ it asks for username and password but when i request http://site.com/filename.fileextension it let me download the file without authentication
I’m fairly new in this domain and I have to say that this site saved me days of trouble! Thank you, honestly, for what you’ve put togather here!
About this snippet, I can’t really get this to work properly! It asks for user and password when I try to access the protected folder but it gives me a 500 error. Is there anything that I miss on settig this snippet? It really messed me for good…
Thanks in advance!