如何使用 .htaccess 密码保护 WordPress 博客

发布于 2024-12-28 02:03:48 字数 474 浏览 1 评论 0原文

这个问题是关于我的电脑上在本地网络上共享的本地主机的。我希望选定的人使用 .htaccess 方法或类似的方法访问该网站。我将以下代码用于 .htacces/.htpasswd 方法

// .htaccess file
AuthName "Realm name"
AuthType Basic
AuthUserFile .htpasswd
require valid-user 


// .htpasswd file
frances:WrU808BHQai36

此方法应该是工作,但它对我不起作用。我曾经收到要求输入用户名和密码的对话框,但再也没有出现过?这个方法在本地主机上有效吗?注意:我的 WordPress 博客位于 C:\blog 文件夹中,该文件夹位于 XAMPP HTDOC 文件夹之外。

This question is with respect to local host on my PC which is shared on the local network. I want selected people to access the website using .htaccess method or something similar. I used the following code for .htacces/.htpasswd method

// .htaccess file
AuthName "Realm name"
AuthType Basic
AuthUserFile .htpasswd
require valid-user 


// .htpasswd file
frances:WrU808BHQai36

This method is suppose to work but it is not working for me. I once got the dialog box asking for username and password but never again? Does this method work on localhost. Note: my wordpress blog is sitting in C:\blog folder which is outside XAMPP HTDOC folder.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

情愿 2025-01-04 02:03:48

您的浏览器将在输入您的信息时存储您的身份验证,因此您只需要进行一次身份验证。要解决此问题,请清除缓存/cookie,然后系统会再次提示您输入密码。

Your browser will store your authentication on entering in your information so you only will need to authenticate once. To fix this, clear your cache/cookies and you should get prompted for a password again.

烟若柳尘 2025-01-04 02:03:48

我遇到了两个问题。一是.htaccess 文件错误,二是密码加密错误。修复此问题后一切正常。注意:我访问了许多网站,但它们的加密对我不起作用。

// 1. note the /blog/ folder needs to be there. 
// Without it, the dialog box does not pop again

AuthName "Restricted Area" 
AuthType Basic 
AuthUserFile /blog/.htpasswd 
AuthGroupFile /dev/null 
require valid-user

为了正确加密 XAMPP 1.7.6,此网站生成的密码对我有效,但对于许多其他的却没有。

有些甚至提供了完整的 htaccess 和 htpasswd 重写像这个,但它对我不起作用。

There were two problems that I were having. One was wrong .htaccess file, the other was wrong password encryption. After fixing this everything worked fine. Note: I visit a number of site and their encryption did not work for me.

// 1. note the /blog/ folder needs to be there. 
// Without it, the dialog box does not pop again

AuthName "Restricted Area" 
AuthType Basic 
AuthUserFile /blog/.htpasswd 
AuthGroupFile /dev/null 
require valid-user

For correct encryption for XAMPP 1.7.6, the password generated by this site worked for me but for many other it did not.

Some provided even complete htaccess and htpasswd rewrite like this one but it did not work for me.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文