Store Logo My Account  Cart Contents  Checkout  
  Home » Catalog » Apache » Setting up an .htaccess Protected Directory Log In |  Cart Contents  |  Checkout | 
Categories
box
Guitars->

Mandolins->

Banjos->

Fiddles

Accessories->

CDs, DVDs and Books->

MP3s

Dulcimer

View All Products ->

All Products sorted by Categories ->

All Products sorted by Manufacturers ->
box
Quick Find
box
 
Use keywords to find the product you are looking for.
Advanced Search
box
Links more
box
CRE Loaded
box
Articles
box
New Articles (0)
All Articles (2)
Apache (2)
box
Setting up an .htaccess Protected Directory by Article Author

 Installing the .htaccess involves a few steps. The most important thing is to make sure you do not install the .htaccess  file in your main web directory. If you do, everyone will be locked out of your website. Unless this is what you want to do, make sure you create the directory and are located in it before creating the file.

    * Step 1: See where you are. At your prompt enter the command pwd to see what directory you are in. If you already have made your new directory and are in it- go to Step 3.

    * Step 2: issue the command mkdir dirname where dirname is what you want to call the directory you will be protecting. Then enter the command cd dirname

    * Step 3: Using an editor such as vi or pico, create a file called .htaccess (lower case letters of course- with the leading period) that looks just like this:

AuthUserFile /usr/www/dirname/.htpasswd
AuthGroupFile /dev/null
AuthName "The Secret Page"
AuthType Basic

<Limit GET POST>
require valid-user
</Limit>

    * Step 4: Change the AuthUserFile so that the UNIX PATH matches that of your system. This is where the password file that we will create in a moment will reside.

    * Step 5: Change The Secret Page to be whatever title you want to have appear on the password box.

    * Step 6: To create the password file, issue the following command: (NOTE: you only do it this way to create a new file)

htpasswd -c .htpasswd user_name (where user_name is a name)

    If you get a message like, htpasswd: not found enter the command type htpasswd. If that doesn't do the trick, try which httpd. If htpasswd is not in your path, you will have to add that directory to your path or enter the command as /what/ever/dir/htpasswd -c user_name

    * Step 7: The system will ask you to enter the password for this user. It will then ask you a second time to confirm your typing.

    * Step 8: Continue to add new users, but with this version of the command. The -c option is only for the initial creation of the file.

htpasswd .htpasswd new_name

That is all there is to it!

Note: If you experiance any problem, seek support from your hosting company ;-) 

This article was published on Wednesday 19 March, 2008.
Current Reviews: 0 Write Review
Tell a friend
box
Tell a friend about this article:  
box
Your Account
box
Your Email Address
Your Password
box
Cards We Accept
box
BOX_INFORMATION_CARD
BOX_INFORMATION_CARD
box
Faq
box
test
box
Information
box
Terms and Conditions
Shipping and returns
Privacy
Gift Voucher FAQ
Links
Contact Us
box
Article Search
box

Search Articles Text
box

Copyright 2008 Mike Cartwright