Access control with Apache .htaccess | Drupal 8

Access control with Apache .htaccess

Submitted by editor on Tue, 06/28/2016 - 21:15
Question

How to control access using Apache's .HTACCESS file ?

1. Access control by IP : (Example)

order deny,allow
deny from all
allow from [YOUR_IP_ADDRESS]

2. By password :

AuthType Basic
AuthName "Password Protected Area"
AuthUserFile /path/to/.htpasswd
Require valid-user

The Password file (.htpasswd) must have users list with encrypted passwords like:

test:dGRkPurkuWmW2

3. Add new user using htpasswd

Example : Create password file and add a new user
htpasswd -c /path/to/.htpasswd username
Example : Add to File
htpasswd /path/to/.htpasswd username
Example: Print to terminal
htpasswd -n username

 

And Also

Set Error Documents

ErrorDocument 403 path/to403.html
ErrorDocument 404 path/to404.html

Tags

Add new comment

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.