How do I password protect one of my web directories?
How do I add a user?
How do I remove a user?
How do I keep certain people out of my protected directory?
Why do I get a Malformed Header error message when I access my protected directory?
Where can I find more information on .htaccess?
Are there any cheap programs to make this easier?
How do I password protect one of my web directories?
Using a program named htaccess, you can easily password protect your web directories.
First - Create a standard plain text file:
Name the text file '.htaccess' and place it in the directory that you want to password protect. The file should look like this:
# Access file
#(makes file invisible)
<files ".ht*">
order allow,deny
deny from all
</files>
Authtype Basic
Authname "My Private Area"
AuthUserFile /home/sites/loginname/passfilename
<Limit GET>
require valid-user
</Limit>
Then make sure you have one blank line at the bottom of your .htaccess file,
otherwise you will get a Malformed Header error message.
Second - Change the following information in the new text file:
AuthUserFile
- Change: /home/sites/loginname/passfilename to the full path
of the actual file that contains the password info.
- Change loginname to your AllSolutions.NET log in username.
AuthName
- Change 'My Private Area'to something that describes the area you are protecting. It must be in quotes.
This will usually be shown in the dialog box when a browser prompts for a password, like this:
Third - Create the password file:
Using a Secure Shell program, log on to your account and at the prompt, type:
htpasswd -c /home/sites/loginname/passfilename newmember
Where /home/sites/loginname/passfilename is the same path you specified in the .htaccess file.
(This creates a new file called 'passfilename', where all your usernames and encrypted passwords are stored.)
'newmember' is the first user you want to give access to your protected directory.
Now the program will ask you to type in the password, twice. That's it.
How do I add a user?
Use a Secure Shell program to log on to your account and at the prompt, type:
htpasswd /home/sites/loginname/passfilename newmember
Where /home/sites/loginname/passfilename is the same path you specified in the .htaccess file.
Now the program will ask you to type in the password twice.
How do I remove a user?
Download the 'password' file and open it in a text editor and delete the line that starts
with the user's name. The file should look something like this:
johnny:v3laSe4r/.56QM
mary:df56Ty3et5ui
myown:aeRfT.G4/Ri8ja
Then save and close the 'password' file. Upload it back to the server. If your password file gets large, you might want to make a
copy before you alter it, just in case.
How do I keep certain people out of my protected directory?
To block an IP address (or addresses) from accessing your protected directory, right after 'require valid-user' in the .htaccess
file, add a line like this:
deny from 209.75.196.2 ... or...
deny from 209.75 ... or...
deny from www.hacker.org
The 'Limit' secton of the .htaccess file should now look like this:
<Limit GET>
require valid-user
deny from 209.75.196.2
deny from 209.75
deny from www.hacker.org
</Limit>
Why do I get a Malformed Header error message when I access my protected directory?
There could be several reasons why the server would return an error
message to you. The most common are:
- You need to have one blank line at the end of your .htaccess file.
- The .htaccess file has to be in the directory that it is going to password protect.
- If you used a graphical HTML editor to make your web page, then it probably changed some of your code.
Often HTML editors will replace the < and > with &lt; and &gt;
so your code is not parsed by the web browser.
You need to change the &lt; and &gt; with < and > in your HTML
file and save it again. If your HTML editor won't allow you to do this, then
you will need to use a text editor like Notepad or Simpletext.
Make sure your file matches the code in Question 1.
Where can I find more information on this '.htaccess' stuff?
We tried to make this as clear and simple as possible. There are a few other things you can do with htaccess, check out the tutorial at:
http://hoohoo.ncsa.uiuc.edu/docs/tutorials/user.html
Are there any cheap programs to make this easier?
Yes, check out .htaccess manager
Home |
Advantages |
Services |
FAQS |
Support |
Sign Up
|