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