我终于弄明白了。我确实不得不使用 mod_rewrite 引擎。我决心有一个不涉及我必须制作额外文件或目录的解决方案。
相同的文件,没有额外的目录,一个 .htaccess:
# Case we are in the protected area!
RewriteCond %{REQUEST_FILENAME} index.php [OR]
RewriteCond %{REQUEST_FILENAME} !-f [OR]
RewriteCond %{REQUEST_URI} ^(\/){1}$
RewriteCond %{REQUEST_FILENAME} !-d [OR]
RewriteCond %{REQUEST_URI} ^(\/){1}$
RewriteCond %{HTTP_HOST} ^(protected)\.mydomain\.com$
RewriteRule ^(.*)$ admin.php%{REQUEST_URI} [L]
#default rewrite
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
#only protect access to admin.php which is a symlink to index.php
<FilesMatch "admin.php">
AuthUserFile .htpasswd
AuthName EnterPassword
AuthType Basic
require valid-user
</FilesMatch>