我目前正在尝试将两者结合起来 - 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>
谁能看到,我做错了什么?
编辑#1:
<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>