Main Menu
Home
Standard Hosting Package
Extras
Installation
Domain Names
About Dogsbody Hosting
Contact Us
Showcase
Usage Policy
Service Agreement

Customer Menu
Webmail
phpMyAdmin
- - - - - - - - - - - - - - - - - - - - -
Support FAQ

Webmail Login
Username

Password

Your Location Home arrow Support FAQ arrow Webspace arrow How do I password protect an area of my website?
How do I password protect an area of my website? Print

There are two parts to password protecting your site:

  1. Create a password file.
  2. Set the configuration to use this password file.

1. Create a password file

The password file is a text file containing a list of usenames and passwords that you wish people to access your content with. The passwords are encypted when stored in the text file so that other users of the server cannot gain access. While the password file is encrypted it is not advisable to plainly show it to people so the password file should either be stored outside of your web directory or with the filename ".htpasswd" (as the webserver will not serve files beginning ".ht").

We have written a little web app that will allow you to encrypt the username and password you wish to use so that you can add it to your password file.

So, create a text file with a differant username & password on each line in the format "username:encryptedpass" (remember to FTP the file as ASCII).

2. Set the configuration to use this password file

Now you need to tell the webserver how to use this password file and for this we use the good old ".htaccess" file (see other FAQ entries for more details on .htaccess). If you don't already have one in the dir you want to protect then create one, it is just a text file.

Add the following to your ".htaccess" file...

AuthType Basic
AuthName "My Stuff"
AuthUserFile /home/sites/www.example.com/web/dir/.hpasswd
Require valid-user

Replace "My Stuff" with a short description of what you are protecting, this will appear in the popup window that the user sees.

AuthUserFile points to the full path of your password file. Your sites web directory sits under "/home/sites/www.example.com/" where "www.example.com" is the full name of your website.

Upload the ".htaccess" file (as ASCII) and your done. Give it a try.

For a much more in depth document on how authentication is occomplished please see the Apache Authentication Page.


 

Search This Site

Latest News
  • Bid for Middle East peace begins
    The US Secretary of State tells the Israeli and Palestinian leaders they have the "opportunity to end this conflict" as direct peace talks begin.
  • Pakistan trio hit by ICC charges
    The three Pakistan cricketers accused of corruption - Salman Butt, Mohammad Asif and Mohammad Amir - have been charged, and provisionally suspensed, by the International Cricket Council.
  • PM backs Hague over aide rumours
    David Cameron supports William Hague "100%" following speculation about the foreign secretary's private life, the PM's spokeswoman says.
  • Explosion on Gulf of Mexico rig
    An explosion rips through an offshore oil rig in the Gulf of Mexico, west of the site of the blast in April that caused a huge oil spill.
  • Ministers propose 45p drink price
    The Scottish government says drinkers should be charged a minimum of 45p for every unit of alcohol as part of efforts to cut consumption.
  • Strike 'kills Afghan civilians'
    Ten election campaign workers have been killed in an air strike by Nato-led forces in Afghanistan, Afghan officials say.
  • RBS to cut a further 3,500 jobs
    Royal Bank of Scotland is planning to cut 3,500 jobs from its technical and back office division.
  • Burger King is sold for $3.26bn
    Burger King is being sold to private equity firm 3G Capital in a deal valued at $3.26bn (£2.1bn), it has been announced.



Copyright © 2003-2010 Dogsbody Hosting