我如何密码保护基本的HTML页面? [英] How can I password protect a basic HTML page?

查看:321
本文介绍了我如何密码保护基本的HTML页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以使用的最简单的密码保护形式是什么,这不需要超级安全,只是防止痞子?理想情况下,它可以添加到由HTML和JavaScript构成的网站上。



它还需要在所有浏览器中运行(不能正确地允许用户切换浏览器,因此它们可以访问密码保护网站的内容!)

Javascript的提示功能似乎被IE过滤掉了,所以这是不可能的。

解决方案

使用由您的Web服务器提供的HTTP基本验证。在Apache中,只需在 .htaccess 或vhost配置中进行配置。在IIS中,它是一个简单的GUI选项。



以下是 Apache docs。,这里是 IIS文档(这是IIS6,但我认为它在IIS7中仍然是一样的)



常见的Apache配置如下所示:

  AuthUserFile / path / to / htpasswd-file $ 
AuthType Basic
需要用户名username1 username2


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.

解决方案

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

这篇关于我如何密码保护基本的HTML页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆