Alex Baranosky
Alex Baranosky

Reputation: 50094

How can I password protect a basic HTML page?

What is the simplest possible form of password protection I can use, that doesn't need to be super secure, just keep out the riffraff? It ideally can be tacked onto a website made of HTML and javascript.

It also needs to work in all browsers (can't rightly allow users to just switch browsers so they can access the contents of the password-protected site!)

Javascript's prompt function seems to be filtered out by IE, so that is out of the question.

Upvotes: 2

Views: 1979

Answers (1)

Michael Berkowski
Michael Berkowski

Reputation: 270727

Use HTTP basic authentication, as provided by your web server. In Apache, this is configured simply in your .htaccess or vhost configuration. In IIS, it is a simple GUI option.

Here are the Apache docs., and here are the IIS docs. (this is IIS6, but I think it's still the same in IIS7)

A common Apache configuration looks something like this:

AuthUserFile /path/to/htpasswd-file
AuthName "String to display in login popup"
AuthType Basic
require user username1 username2

Upvotes: 6

Related Questions