http - Apache 身份验证 : Redirect on failure, 可靠吗?

标签 http redirect apache basic-authentication

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

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

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

最佳答案

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

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

<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 身份验证 Hook 的 php 等语言

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

关于http - Apache 身份验证 : Redirect on failure, 可靠吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1726860/

相关文章:

ios - NSURLSession 后台 session 的正确用例是什么?

php - $_POST 在 php5.6 中为空

python - 如何在 Pyramid 中 POST 后重定向?

Windows命令行重定向下的c++换行符

Apache 重定向和 HTTPS

php - EC2 Mod Rewrite 将 AllowOverRide None 更改为 All

http - 从Flutter中的api获取后如何拆分文本数据

Java 和 PHP POST 请求不起作用

php - 在 PHP 中从 $_POST[] 读取数据

ssl - 如何强制或重定向我的 next.js 网站以使用 https