我在根目录中安装了 codeigniter,并希望使用 htaccess 保护一个名为“test”的子目录密码。无论我尝试什么,我都会不断收到“找不到 404 页面”。目录结构为:
/public_html
/css
/images
/system (codeigniter directory)
/test
.htaccess
.htaccess
.htpasswd
index.php
根 .htaccess 文件如下所示:
RewriteEngine On
RewriteBase /
Options -Indexes
# Removes trailing slashes
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ $1 [L,R=301]
# Enforce www
RewriteCond %{HTTP_HOST} !^(www) [NC]
RewriteRule ^(.*)$ http://www.mydomain.com/$1 [L,R=301]
#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^(.*)test(.*)
RewriteRule ^(.*)$ index.php?/$1 [L]
/test/.htaccess 文件:
AuthUserFile /home/dir/.htpasswd
AuthName "Protected Area"
AuthType Basic
<limit GET POST PUT>
require user adminuser
</limit>
当我导航到 URL“ http://www.mydomain.com/test/ ”时,我什至没有收到身份验证提示,只有 codeigniter 404 页面。
请指教!