Start a conversation

Basic .htaccess features: access control

The .htaccess file allows you to set different types of restrictions depending on your individual needs.

1. You can deny all users access to the directory in which this file is located. To do this, use the following directives:

Order Deny,Allow

Deny from all

2. You can restrict access for all users, except for the one that will connect from the IP address: xxx.xxx.xxx.xxx.

order deny,allow

deny from all

allow from xxx.xxx.xxx.xxx

3. You can do the opposite: open access to all users, except for the one that will connect from the IP address: xxx.xxx.xxx.xxx.

Order allow,deny

Allow from all

Deny from xxx.xxx.xxx.xxx

4. There are also directives prohibiting access only to a specific file (for example, the example.html file):

<Files example.html >

Order allow,deny

Deny from all

5. Restricting access using a password and login. The following directives are used:

AuthType Basic    

AuthName "Directory"

AuthUserFile /home/username/public_html/.htpasswd

require valid-user

Designation:

- Directory – the name of the directory, you want to restrict access to,

- /home/username/public_html/.htpasswd – this is the path to the file that contains the login and password of authorized users.

The entries in the .htpasswd file are user:password

Choose files or drag and drop files
Was this article helpful?
Yes
No
  1. Oleksii Momot

  2. Posted
  3. Updated

Comments