【问题标题】:.htaccess throws 404.htaccess 抛出 404
【发布时间】:2018-06-06 14:29:07
【问题描述】:

我有一个带有重写规则的 .htaccess:

RewriteEngine On
RewriteRule   ^admin/.*$ - [L]
RewriteRule !\.(gif|jpg|png|css|js|ico|htc|txt|swf|pdf)$ index.php
ErrorDocument 404 /404.php
#AddHandler php5-script .php
Options -Indexes

基本上,它会将所有文件发送到 index.php,除了 /admin/ 文件夹和上面的文件类型。它工作得很好,但我需要用 .htaccess 保护 /admin/ 文件夹:

AuthName "Area Admin"
AuthUserFile "/path/to/folder/passwd/"
AuthType Basic
require valid-user

当我保护文件夹时,/admin/ 停止工作并开始抛出 404。如果我删除它,它就可以正常工作。

【问题讨论】:

  • 当你说保护?你的意思是你想要一个用户名和密码,但仍然给?访问?

标签: .htaccess authentication http-status-code-404


【解决方案1】:

使用您的权限在 admin 文件夹根目录中添加 .htaccess。这样,它会将自己从您的主 .htaccess 文件中排除,并在您访问该文件夹时要求提供凭据。

【讨论】:

  • 当我说添加 .htaccess 时,我的意思是在您的根目录中添加第二个 .htaccess 并删除您尝试添加到主文件的文件权限,并将它们添加到管理员 .htaccess 中。希望这是有道理的。
猜你喜欢
  • 1970-01-01
  • 2015-09-28
  • 1970-01-01
  • 1970-01-01
  • 2013-11-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-02-15
相关资源
最近更新 更多