服务器 Gind.cn

服务器问题集锦,包括 Linux(Ubuntu, Centos,Debian等)和Windows Server服务器

阻止redirect到特定的REQUEST_URI

我已经添加了一个目录到我的网站的公用文件夹,并在其中放置了下面的.htaccess文件: AuthName "Restricted Area" AuthType Basic AuthUserFile /path/to/.htpasswd AuthGroupFile / Require valid-user .htpasswd文件存在并具有有效的内容。 在该站点的公用文件夹中,有一个带有以下重写规则的.htaccess文件: RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . index.php 有了这个设置,我的/protected文件夹不受保护。 如果我不改变重写规则,Apache似乎没有读取我的/protected/.htaccess文件,并且我的/protected文件夹不受保护。 如果我评论重写,试图访问我的/protected目录会导致密码提示,正如所料。 我修改了根.htaccess重写规则,我应该阻止mod_rewrite尝试重写请求到/protected文件夹,如下所示: RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} !^/protected RewriteRule . index.php 但是这似乎没有影响: 该请求似乎是由/index.php处理的,而不是像预期的那样提示authentication细节 /protected文件夹不受保护 该网站的其余部分正常工作 在我的受保护的文件夹中还有一个index.php文件( /protected/index.php ),内容如下: die('protected'); 任何人都可以看到这种方法的问题,或与我的修改根.htaccess重写规则?