我试图密码保护文档根,我得到的是一个“内部服务器错误”页面。 Apache错误日志显示:
Invalid command 'AuthType', perhaps misspelled or defined by a module not included in the server configuration
任何重写条目之前我的.htaccess文件:
AuthType Basic AuthName "Restricted Access" AuthBasicProvider file AuthUserFile /var/www/public/.htpasswd Require user dean
我检查了模块是否启用:
Array ( [0] => core [1] => mod_so [2] => mod_watchdog [3] => http_core [4] => mod_log_config [5] => mod_logio [6] => mod_version [7] => mod_unixd [8] => mod_access_compat [9] => mod_alias [10] => mod_auth_basic [11] => mod_authn_file [12] => mod_authz_core [13] => mod_authz_groupfile [14] => mod_authz_host [15] => mod_authz_user [16] => mod_autoindex [17] => mod_cgi [18] => mod_dav [19] => mod_dav_fs [20] => mod_deflate [21] => mod_dir [22] => mod_env [23] => mod_filter [24] => mod_mime [25] => mod_negotiation [26] => mod_php5 [27] => prefork [28] => mod_reqtimeout [29] => mod_rewrite [30] => mod_setenvif [31] => mod_socache_shmcb [32] => mod_ssl )
我的Apache版本在Ubuntu 14.04上是2.4.10
看来AuthType是由Apache 2.4中的mod_authn_core提供的。 我没有看到你提供的列表中加载的模块。
我使用的是Server version: Apache/2.2.15 ,在启动服务器时出现同样的错误。
我已经启用模块mod_authn_file和mod_auth_basic 。 现在正常工作!