User Tools

Site Tools


blog:apache_htaccess_for_ip_or_auth_based_access

Apache htaccess for ip or auth based access

Create a password file with a hard to guess name like ~/.htpass87s9adf with usernames and passwords using the commands

htpasswd -B USERNAME PASSWORD PASSWORDFILE
chmod o+r PASSWORDFILE

Create a file .htaccess using and adapting the following content. In the lines Allow from you can add IP addresses which will have access without password authentication.

Options -Indexes

AuthName "Authorisation required"
AuthUserFile /home/user/PASSWORDFILE
AuthGroupFile /dev/null
AuthType Basic
require valid-user

Order deny,allow
Deny from all

Allow from x.y.z.w
Allow from .......

Satisfy Any

~~LINKBACK~~

Discussion

Enter your comment. Wiki syntax is allowed:
   ___  __  __   __   ____    ___ 
  / _ | \ \/ /  / /  / __ \  / _ )
 / __ |  \  /  / /__/ /_/ / / _  |
/_/ |_|  /_/  /____/\____/ /____/
 
blog/apache_htaccess_for_ip_or_auth_based_access.txt · Last modified: 2022-12-20 14:09 by brb