.htaccess AuthType基本文件匹配401和403 解决方案

问题描述

我们正在网站上进行一些重要工作,我们希望限制对除维护页面以外的所有文件的访问。如果取消或失败授权请求,我们希望将所有用户定向到该页面。

    ErrorDocument 401 /home/user/public_html/maintenance.html
    ErrorDocument 403 /home/user/public_html/maintenance.html
    <FilesMatch ^>
    AuthName "Authorized Only"
    AuthType Basic
    AuthUserFile .htpasswd
    require valid-user
    </FilesMatch>
    <Files "/home/user/public_html/maintenance.html">
        Allow from all
    </Files>

此代码似乎不起作用,用户被发送到一个页面,上面写着:

    Unauthorized

    This server could not verify that you are authorized to access the document requested. 
    Either you supplied the wrong credentials (e.g.,bad password),or your browser doesn't 
    understand how to supply the credentials required.
    
    Additionally,a 401 Unauthorized error was encountered while trying to use an ErrorDocument 
    to handle the request.

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)