|
Answer by: Andrew Hickl, Aplus.Net Knowledge
Base Support
If you plan to password protect directories
using .htaccess files, you will need to create a working .htpasswd
file first. Here’s how:
*Begin by creating the .htpasswd file
itself.
- Open
up a text editor on your computer. We recommend that you use Notepad
(Windows), SimpleText (Macintosh), or Emacs (Linux / UNIX).
- Save
the file (in an easy-to-find location) as .htpasswd (including
the initial dot).
- Now,
make sure that your text editor did not append a .txt suffix to
the file name. (In Windows, you can do this by right-clicking the
icon for the text file and selecting “Properties”.)
If the file name does have a .txt suffix (i.e. ‘.htpasswd.txt’),
remove the suffix by renaming the file.
- Before
entering code into your new file, make sure that “Word Wrap” is
turned off. (In Notepad, select “Format…” from
the top navigation bar and make sure that “Word Wrap” is
unchecked.
*You’re now ready to add some users.
- Begin
by selecting the username that you will use to log-in to the protected
directory. (Usernames can be between 2 and 16 characters long and
should only contain lower-case letters and numbers.)
- Type
the username into the .htpasswd file followed by a colon. Your
file should look like this:
- You’ll
now need to encrypt the password that you will use to log-in to
the directory. To do this, visit http://users.abac.com/cgi-bin/pass.pl. On
this page, enter your password (up to 13 characters) and hit the “Submit” button – the
encrypted password will be displayed on the following page.
Important:
The encrypted password will always be 13 characters long, regardless
of the actual length of your password.
- Copy
the encrypted password from the webpage and paste it into your
.htpasswd file following the colon. Be sure to remove any spaces
that may precede or follow the password. Your file should look
like this:
- To
add additional users, end the current line with a carriage return
and repeat steps (5) through (8) above on the next line.
- When
you’re done adding users, save the file.
*Uploading the .htpasswd File
- Open
your FTP client and establish a connection to your web space using
your FTP Username and FTP Password. Your connection URL should
be www.yourdomainname.com (where ‘yourdomainname.com’ =
the actual name of your domain).
- Browse
to the root directory of your website. This is important: uploading
your .htpasswd file to another directory may cause unexpected consequences.
- Set
your upload settings to ASCII. (Uploading .htpasswd files in ‘binary’ format
may have unexpected consequences.)
- Upload
your .htpasswd file from your local computer. Be sure not overwrite
an existing .htpasswd file – you may lose whatever login
information is stored in that file.
Important:
If you have an existing .htpasswd file in your root directory, we
suggest that you add the usernames and passwords contained in that
file to your new .htpasswd file before uploading it to the web. You
can do this by first downloading the old .htpasswd file and copying
and pasting its content into your new file.
- After
the upload is completed, you may need to change the file permissions
for the .htpasswd file. They should be set to 644 (using chmod)
or RW-R--R--.
Important: If you have a Windows-based hosting plan, you cannot
use .htaccess files.
|