Apache basic authentication

In .htaccess:

AuthType Basic
AuthName "Restricted Files"
AuthUserFile /the/location/of/.htpasswd (or /the/location/of/whatever/pass/file)
Require user the_username

In vhost:

<VirtualHost *:80>
  ServerName www.example.com
  ServerAdmin webmaster@example.com
  DocumentRoot /var/www/example
	...
  <Directory /var/www/example>
    AuthType Basic
    AuthName "Restricted Files"
    AuthUserFile /the/location/of/.htpasswd (or /the/location/of/whatever/pass/file)
    Require user the_username
  </Directory>
</VirtualHost>

Last modified: 21/10/2011 Tags:

This website is a personal resource. Nothing here is guaranteed correct or complete, so use at your own risk and try not to delete the Internet. -Stephan

Site Info

Privacy policy

Go to top