简体   繁体   English

如何设置.htaccess密码保护提示的样式?

[英]How can I style a .htaccess password protection promp?

I've just been messing around with setting a password protected directory on my webserver (so as to store hot copies of backups etc.) and was wondering if there's any way I may be able to style the password prompt that appears when a user attempts to access this page. 我刚刚在我的网络服务器上设置一个受密码保护的目录(以便存储备份的热拷贝等)并且想知道是否有任何方式我可以设置用户尝试时出现的密码提示的样式访问此页面。

默认提示的屏幕截图

As it stands nobody will notice my nice little note, which makes me sad. 在现在,没有人会注意到我的小笔记,这让我感到难过。

我的提示

It seems to display similarly to a standard .js alert, though I've been unable to find a way to specify any css classes I may be able to alter, as the "alert" box does not show up in devtools, just the page bahind it: 它似乎与标准的.js警告类似,但是我一直无法找到一种方法来指定我可以改变的任何css类,因为“警报”框没有出现在devtools中,只是页面bahind它:

html源码的截图

Any advice / tips would be greatly appreciated. 任何建议/提示将不胜感激。

You can't edit the authentication login box itself, it's different for every browser and its implemented as part of the browser's internals (for example, a snippet of Chrome's Code dealing with the Login Title: https://code.google.com/p/chromium/codesearch#chromium/src/chrome/app/generated_resources.grd&q=%22Authentication%20Required%22&sq=package:chromium&type=cs&l=3552 ). 您无法编辑身份验证登录框本身,它对于每个浏览器都是不同的,并且它作为浏览器内部的一部分实现(例如,Chrome代码处理登录标题的片段: https//code.google.com/ p / chromium / codesearch#chromium / src / chrome / app / generated_resources.grd&q =%22Authentication%20Required%22&sq = package:chromium&type = cs&l = 3552 )。

What you can do is to create a custom php login page (with popover if you want) to display: 您可以做的是创建一个自定义的PHP登录页面(如果需要,使用popover)来显示:

Redirect 401 "authorization required page" to custom page 将401“授权所需页面”重定向到自定义页面

Custom Login with htaccess through HTML/PHP 通过HTML / PHP自定义登录htaccess

Replace Htaccess popup box with a html form? 用html表单替换Htaccess弹出框?

Add this to .htaccess 将其添加到.htaccess

ErrorDocument 401 /401.html

Then in your root directory (where your index.html is) make your own 401.html file. 然后在您的根目录(index.html所在的位置)创建自己的401.html文件。 If you want to make the login work, however, you'll need a server side language like PHP. 但是,如果要使登录工作,则需要像PHP这样的服务器端语言。

如何更改警报框的样式,除非您创建自己的警报对话框,否则无法更改警报框的样式(有关示例,请参阅此处

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM