htaccess 重定向到 404 时如何访问受密码保护的目录?
我安装了一个 WordPress,其中包含以下 htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_URI} !^/secure-area/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
和一个目录 /public_html/secure-area/
已使用 cPanel 进行保护。
- 如果我在Wordpress中关闭prettylinks,我可以正常访问该目录,但否则,我会被重定向到WP 404页面。
- 我可以毫无问题地访问不受密码保护的目录。
我在这里问是因为这是一个 htaccess 问题,而不仅仅是 wordpress 特有的问题,而且我在这里看到的答案似乎更合格。
非常感谢,蒂姆
类似的问题不解决密码保护的目录:
I have a wordpress install with the following htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_URI} !^/secure-area/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
and a directory /public_html/secure-area/
which has been protected using cPanel.
- If I turn off prettylinks in Wordpress, I can access the directory normally, but otherwise, I am redirected to the WP 404 page.
- I can access a directory that is not password protected without any problems.
I'm asking here because this is an htaccess problem, not just wordpress specific, and the answers I've seen over here seem better qualified.
Many thanks, Tim
Similar questions which don't address password protected directories:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我遇到了同样的问题,这对我有用: http ://support.aiso.net/index.php?_m=knowledgebase&_a=viewarticle&kbarticleid=246
只需将 401 错误文档行切换为:
错误文档 401 默认值
I was having the same problem and this worked for me: http://support.aiso.net/index.php?_m=knowledgebase&_a=viewarticle&kbarticleid=246
Just switch the 401 Error Document line to read:
ErrorDocument 401 default
404 是由于没有“401”错误文档 - 默认情况下由 cpanel 指定,但主机通常不会设置。我创建了一个空白文档并将其添加到我的 .htaccess 中:
我这样做是为了在有人污损我的网站后保护我的 wp-admin 文件夹免受未来/未知的 Wordpress 攻击。
The 404 is from not having "401" Error document - one is specified by default with cpanel but not usually not set up by the host. I created a blank document and added this to my .htaccess:
I did this to protect my wp-admin folder from future/unknown Wordpress exploits after someone defaced my site.
我在 cPanel 下也遇到了同样的问题。就我而言,这是由于“~/.htpasswds/public_html/secure-dir/passwd”文件/目录没有正确的权限。我打电话给托管公司,他们使用正确的权限对该文件进行了 chown,并且它起作用了。
这确实让我感到困惑,因为它看起来目录保护正在工作,因为它弹出了 AUTH 窗口。但是当 Apache 去验证 passwd 时,它会阻塞并提供 WP 标准 404 页面。
I had this same problem under cPanel. In my case it was due to the "~/.htpasswds/public_html/secure-dir/passwd" file/directory not having the correct permissions. I called the hosting company and they chown'd the file with the correct permissions and it worked.
It really had me stumped in that it looked like the directory protection was working b/c it was popping up the AUTH window. But when Apache went to verify the passwd it would choke and serve the WP standard 404 page.
我仍然有兴趣解决这个问题,因为我想要一个便携式解决方案,但我的解决方法是删除密码保护并限制对我自己的 IP 地址的访问。
我在 /secure-area/ 目录中添加了一个 htaccess 文件,其中包含以下代码 Perishable Press - Studpid htaccess技巧:
我在那里运行了一些脚本,所以我还添加:
为了便于使用,考虑到它(应该是)一个安全目录。
我有兴趣听听这是否是一种愚蠢、不安全的处理方式:) Ta
I'm still interested in solving this, because I'd like a portable solution, but my workaround is that I've removed password protection and restricted access to my own IP address.
I added an htaccess file in the /secure-area/ directory with the following code from Perishable Press - Studpid htaccess tricks:
I've got a few scripts i run in there, so i also add:
for ease of use, given that it (should be) a secure directory.
I'm interested in hearing whterh this is a silly, insecure way of going about things :) Ta
将其添加为 htaccess 中的第一行。为我的 WordPress 网站工作,该网站不断重定向到 404 页面。
Add this as the first line in htaccess. Worked for my wordpress site which kept redirecting to 404 page.