我目前正在尝试将两个 - htaccess密码保护和mod_rewrite结合起来。我的问题是,下面的代码导致错误:“没有指定输入文件。”
<IfModule mod_rewrite.c>
Options +FollowSymLinks -MultiViews
DirectoryIndex index.php
AuthType Basic
AuthName "Password Protected Area"
AuthUserFile .htpasswd
Require valid-user
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteRule ^$ public/ [L]
RewriteRule (.*) public/$1 [L]
</IfModule>
任何人都可以看到,我做错了吗?
<IfModule mod_rewrite.c>
Options +FollowSymLinks -MultiViews
DirectoryIndex index.php
AuthType Basic
AuthName "Password Protected Area"
AuthUserFile /.htpasswd
Require valid-user
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NE]
RewriteRule ^((?!public/).*)$ public/$1 [L,NC]
</IfModule>
答案 0 :(得分:0)
确保AuthUserFile
具有有效加密密码文件的完整路径。
其余的代码,请这样:
<IfModule mod_rewrite.c>
Options +FollowSymLinks -MultiViews
DirectoryIndex index.php
AuthType Basic
AuthName "Password Protected Area"
AuthUserFile /full/path/to/.htpasswd
Require valid-user
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NE]
RewriteRule ^((?!public/).*)$ /public/$1 [L,NC]
</IfModule>