Chrome 中未显示 .htaccess 中的 AuthName
AuthName in .htaccess not displayed in Chrome
我正在尝试使用 Apache2 保护带有 .htaccess
文件的网站。它运行良好,但 AuthName
行指定的消息在 Chrome 上不可见(但在 Firefox 上可见!)。我应该怎么做才能让它在 Chrome 上可见?
这是我的 .htaccess
文件
AuthType Basic
AuthName "Restricted Access"
AuthFile "/etc/apache2/.htpasswd"
Require valid-user
在 Firefox 上,弹出窗口告诉
The site ... is requesting your username and password. The site says: "Restricted Access"
但在 Chrome 它只告诉
Sign in
What should I do to make it visible on Chrome?
你无能为力。
浏览器决定是否要以某种方式向用户显示此信息。
Apache 文档中使用的措辞已经暗示了这一点(我的重点)-
https://httpd.apache.org/docs/2.4/mod/mod_authn_core.html#authname:
The string provided for the AuthName is what will appear in the password dialog provided by most browsers.
https://httpd.apache.org/docs/2.4/howto/auth.html#gettingitworking:
The AuthName directive sets the Realm to be used in the authentication. The realm serves two major functions. First, the client often presents this information to the user as part of the password dialog box. Second, it is used by the client to determine what password to send for a given authenticated area.
这里有一个解决方法,可以在登录尝试失败后使用自定义错误文档功能,为不幸的访客提供一些信息:
将此行放入您的 .htaccess 文件中:
ErrorDocument 401 YYYY-MM-DDTHHMM-Site-update-under-way-Estimate-30-min
登录失败或取消后,似乎显示连续的文字。不允许使用点 (.) 或冒号 (:)。当然,它应该代表一个有效的文件名,但是如果用户由于登录失败而无法访问 public_html,则可能无论如何都无法提供文件。如果您可以提供适当的 401 错误页面,您可以在那里解释情况。
(edit 1) 也许这种行为是我对共享主机的好奇心。那里的共享服务器似乎是 nginx,我猜它“被迫”接受 .htaccess 指令。
(编辑 2)也通过 Apache 2.4 服务器确认了此行为
我正在尝试使用 Apache2 保护带有 .htaccess
文件的网站。它运行良好,但 AuthName
行指定的消息在 Chrome 上不可见(但在 Firefox 上可见!)。我应该怎么做才能让它在 Chrome 上可见?
这是我的 .htaccess
文件
AuthType Basic
AuthName "Restricted Access"
AuthFile "/etc/apache2/.htpasswd"
Require valid-user
在 Firefox 上,弹出窗口告诉
The site ... is requesting your username and password. The site says: "Restricted Access"
但在 Chrome 它只告诉
Sign in
What should I do to make it visible on Chrome?
你无能为力。
浏览器决定是否要以某种方式向用户显示此信息。
Apache 文档中使用的措辞已经暗示了这一点(我的重点)-
https://httpd.apache.org/docs/2.4/mod/mod_authn_core.html#authname:
The string provided for the AuthName is what will appear in the password dialog provided by most browsers.
https://httpd.apache.org/docs/2.4/howto/auth.html#gettingitworking:
The AuthName directive sets the Realm to be used in the authentication. The realm serves two major functions. First, the client often presents this information to the user as part of the password dialog box. Second, it is used by the client to determine what password to send for a given authenticated area.
这里有一个解决方法,可以在登录尝试失败后使用自定义错误文档功能,为不幸的访客提供一些信息:
将此行放入您的 .htaccess 文件中:
ErrorDocument 401 YYYY-MM-DDTHHMM-Site-update-under-way-Estimate-30-min
登录失败或取消后,似乎显示连续的文字。不允许使用点 (.) 或冒号 (:)。当然,它应该代表一个有效的文件名,但是如果用户由于登录失败而无法访问 public_html,则可能无论如何都无法提供文件。如果您可以提供适当的 401 错误页面,您可以在那里解释情况。
(edit 1) 也许这种行为是我对共享主机的好奇心。那里的共享服务器似乎是 nginx,我猜它“被迫”接受 .htaccess 指令。
(编辑 2)也通过 Apache 2.4 服务器确认了此行为