Apache 2.4 版本配置文件启用了“mod_rewrite”模块。
LoadModule rewrite_module modules/mod_rewrite.so
身份验证模块加载并共享命令的输出:apachectl -M | grep '身份验证'
auth_basic_module (shared)
auth_digest_module (shared)
authn_file_module (shared)
authn_anon_module (shared)
authn_dbm_module (shared)
authz_host_module (shared)
authz_user_module (shared)
authz_owner_module (shared)
authz_groupfile_module (shared)
authz_dbm_module (shared)
authnz_ldap_module (shared)
authz_core_module (shared)
在 apache2.4 - 应用程序目录的 Web 服务器配置文件
<Directory /var/www/html/logfile>
AllowOverride AuthConfig
Require all granted
</Directory>
.htaccess 文件放在 logfile 目录下
AuthType Basic
AuthName "Restricted Access"
AuthBasicProvider file
AuthUserFile "/home/ec2-user/htpasswd/.htpasswd"
Require user tom
通过 url 访问日志文件,它必须要求 url 身份验证,成功验证后将允许查看文件。
但它会生成500 - Internal server Error并共享 apache 服务器日志
.htaccess:无效命令“AuthType”,可能拼写错误或由服务器配置中未包含的模块定义