当我试图添加AuthType时,当我输入密码时,我的站点就不能工作了。你知道怎么回事吗?
我的错误是500。但是如果没有AuthType,它就能工作
AuthType Basic
AuthName "restricted area"
AuthUserFile .htpasswd
require valid-user
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule (.*) https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Options All -Indexes -MultiViews
RewriteCond %{DOCUMENT_ROOT}/$1.html -f [NC]
RewriteRule ^(.+?)/?$ $1\.html
RewriteCond %{REQUEST_URI} ^$1/index [NC]
RewriteRule ^ - [L]
RewriteRule ^en/ - [L]
RewriteRule ^pl/ - [L]
RewriteCond %{HTTP:Accept-Language} !^pl [NC]
RewriteCond %{REQUEST_URI} !^/assets [NC]
RewriteCond %{REQUEST_URI} !^/js [NC]
RewriteCond %{REQUEST_URI} !^/lib/sendmail.php [NC]
RewriteCond %{REQUEST_URI} !^/robots.txt [NC]
RewriteCond %{REQUEST_URI} !^/sitemap.xml [NC]
RewriteRule ^ /en%{REQUEST_URI} [L]
RewriteCond %{HTTP:Accept-Language} ^pl [NC]
RewriteCond %{REQUEST_URI} !^/assets [NC]
RewriteCond %{REQUEST_URI} !^/js [NC]
RewriteCond %{REQUEST_URI} !^/lib/sendmail.php [NC]
RewriteCond %{REQUEST_URI} !^/robots.txt [NC]
RewriteCond %{REQUEST_URI} !^/sitemap.xml [NC]
RewriteRule ^ /pl%{REQUEST_URI} [L]发布于 2022-03-08 05:31:09
参考https://httpd.apache.org/docs/2.4/mod/mod_authn_core.html#authtype
AuthType只能包含在<Directory>语句或.htaccess文件中。因此,您必须指定一个目录,如下所示:
<Directory "/www/htdocs">
YOUR AUTH CONFIGURATION HERE
</Directory>它不允许像你那样拥有它。如果要使用此方法保护整个站点,可以将<Directory>子句设置在与DocumentRoot值相同的目录上。
https://stackoverflow.com/questions/71386890
复制相似问题