Publishing System Settings Logout Login Register
Everything you need to know about .htaccess! Massive tutorial!
TutorialCommentsThe AuthorReport Tutorial
Tutorial Avatar
Rating
Add to Favorites
Posted on November 22nd, 2006
8696 views
General Website Development

Password Protect A Directory

The server your site is on needs to have Apache. Or else it will not work...


Moving on..

To protect a directory, the directory needs to exist. So if it doesnt, firstly create the directory.

Now we are going to build up the .htaccess file.

AuthUserFile .htpasswd


This defines the name of the file that holds the usernames and passwords in.

AuthName "Directory name"


This is what will show in the password prompt box.. So the code above would be:

Enter username and password for "Directory Name" at yoursite.com

So change that to how you want it.

AuthType Basic
require valid-user

You do not need to edit this, you just leave as. This tells the server that to enter the directory, you need to be a valid user.

Here is the full code:

AuthUserFile .htpasswd
 AuthName "Directory Namel"
 AuthType Basic
 require valid-user

Save that as .htaccess and place it in the directory you want to protect.

Now thats no good, if we havnt got any usernames & passwords...

So for this, we need to use a generator to generate the encrypted password.

You can find the generator here

So enter the username and password you want, it will give you the code. Place the output in a blank file and save it as .htpasswd

Now upload both files to your directory, and test it. If you followed the tutorial correct, it should work!

You will find both files in the ZIP folder that is available for download at the end of the tutorial. The username and password for the file in the ZIP is:

Username: Test
Password: testing

 

Next Page
Pages: 1 2 3 4 5 6 7 8 9 10
Dig this tutorial?
Thank the author by sending him a few P2L credits!

Send
Adam

This author is too busy writing tutorials instead of writing a personal profile!
View Full Profile Add as Friend Send PM
Pixel2Life Home Advanced Search Search Tutorial Index Publish Tutorials Community Forums Web Hosting P2L On Facebook P2L On Twitter P2L Feeds Tutorial Index Publish Tutorials Community Forums Web Hosting P2L On Facebook P2L On Twitter P2L Feeds Pixel2life Homepage Submit a Tutorial Publish a Tutorial Join our Forums P2L Marketplace Advertise on P2L P2L Website Hosting Help and FAQ Topsites Link Exchange P2L RSS Feeds P2L Sitemap Contact Us Privacy Statement Legal P2L Facebook Fanpage Follow us on Twitter P2L Studios Portal P2L Website Hosting Back to Top