Websites, SEO and web management, London UK.

SEO

Password protect folders

You need 2 files, named .htpasswd and .htaccess to password protect a website or folder; password protect with htaccess and htpasswd.

.htpasswd

.htaccess

	AuthUserFile /home/john/.htpasswd
	AuthGroupFile /dev/null
	AuthName "foo"
	AuthType Basic
	<Limit GET>
		require valid-user
	</Limit>

Place this .htaccess file in to the folder you want protect, sample: /var/www/sample.com/my-protected-folder/.htpasswd (http://sample.com/my-protected-folder/)

Ensure that the Apache conf file something /etc/apache/apache.conf contains a declaration:

	<Directory "/var/www/sample.com/my-protected-folder">
		AllowOverride All
	</Directory>

Scenario 2, over the console

Create a new .htpasswd file

	$ htpasswd -c /path-to-my-secret-place/.htpasswd name-of-user

Update existing or add users

	$ htpasswd /path-to-my-secret-place/.htpasswd name-of-other-user

Instead of using .htpasswd you can configure httpd.conf or apache2.conf, like this:

	<Directory /var/www/mydomain.com/folder/secretfolder>
		AuthType basic
		AuthName "foo"
		AuthUserFile /path-to-my-secret-place/.htpasswd
		AuthGroupFile /dev/null
		<Limit GET>
			Require User name-of-user name-of-other-user
		</Limit>
	</Directory>

Solving a htpassword problem

Tags: .htpasswd, htpasswd generator, htpasswd tutorial, htpasswd htaccess, htpasswd file, htpasswd example, htpasswd howto.

2010

Web Management - website set up, domain administration, DNS administration, server administration, site maintenance.