How do I restrict access to my
site?
Select or create the directory you are going to restrict on the
server:
Before you can create the files needed to restrict access
to your site you must
decide which directory you want to protect. If you need to create
a directory do
so now. *Permissions must be set to 755 on this directory.
The .htaccess file:
Edit the following code for your site then copy and paste
into a text editor. Ensure your text editor does not use
any word-wrapping. Save to a file named .htaccess and
upload it as ASCII Text into the directory you wish to restrict
access on.
# Access file
order allow,deny
allow from all
require valid-user
Authname "DirectoryName"
AuthPAM_Enabled off
Authtype Basic
AuthUserFile /home/sites/www.YOUR_DOMAIN.COM/web/DirectoryName/.htpasswd
|
The .htpasswd file:
Now we need to create the .htpasswd file. Select the
username and password you will be using
and use the form below. Cut and past the resulting text to a file and
save as .htpasswd
This should also be uploaded as ASCII Text into the directory you
wish to restrict access on.
*Usernames and Passwords ARE case sensitive.
FAQ:
I uploaded my .htaccess and .htpasswd file but now I can't see
them?
Because of the type of file you've uploaded most FTP programs
will not display them. If
you need to 'see' these files you will have to ftp in via DOS and
use the ls -al command or with WS_FTP, you can type in the
"empty white box under the MkDir button" -la , then hit enter and you will see
hidden files.. If you need help with you FTP program, please
contact the software manufacture.
I get a 'Forbidden' error and
or nothing happens after entering username/password.
This is caused when the permissions on the directory are
not set correctly, it must be 755
in order for this to work. Check you FTP help if you are not
familiar with how to chmod.
Can I have more than one
username/password?
Yes, add each user:password to a new line in the .htpasswd
file