Apache 身份验证:失败时重定向,可靠吗? [英] Apache authentication: Redirect on failure, reliably?

查看:28
本文介绍了Apache 身份验证:失败时重定向,可靠吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将 ErrorDocument 401 设置为指向我网站的帐户创建页面,但似乎并非所有浏览器都支持此重定向 (Safari).

I've set my ErrorDocument 401 to point to my website's account creation page, but not all browsers seem to honor this redirect (Safari).

此外,其他浏览器(Firefox、Chrome)永远不会停止询问密码并显示 ErrorDocument.这导致大量用户在多次尝试密码后没有看到帐户创建页面而放弃尝试.

Also, other browsers (Firefox, Chrome) never quit asking for the password and show the ErrorDocument. This causes a good number of users to give up trying after many password attempts without seeing the account creation page.

有什么方法可以使重定向更可靠,同时又不会完全破坏基本身份验证?

Is there any way to make the redirect more reliable, without trashing basic authentication altogether?

推荐答案

对您的问题的简单回答是否定的,如果不实施自定义身份验证,您就无法使其更可靠.

The simple answer to your question is no, you can't make this more reliable without implementing custom authentication.

Firefox 和 Chrome 显示您在 ErrorDocument 401 指令中指定的页面的唯一方式是单击取消按钮.此外,没有使用 401 HTTP 代码发送重定向;相反,它是使用 ErrorDocument 401 指令指定的文档内容.您可以使用 HTML 元标记进行重定向:

The only way that Firefox and Chrome will display page that you specified in the ErrorDocument 401 directive is if you click cancel button. Also, there is no redirect sent with the 401 HTTP code; rather, it is a content of the document specified with ErrorDocument 401 directive. You can do redirect using HTML meta tag:

<Location "/protected">
    AuthUserFile /path/to/users
    AuthName "This is protected area"
    AuthGroupFile /dev/null
    AuthType Basic
    Require valid-user

    #ErrorDocument 401 /register.html
    ErrorDocument 401 "<html><meta http-equiv=\"refresh\" content=\"0;url=/register.html\"></html>"
</Location>

您的问题的可能解决方案是创建自定义的基本 HTTP 身份验证模块或使用支持基本 HTTP 身份验证挂钩的 php 等语言

Possible solutions to your problem are to create custom basic HTTP authentication module or to use language like php that supports basic HTTP authentication hooks

http://php.net/manual/en/features.http-auth.php

这篇关于Apache 身份验证:失败时重定向,可靠吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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