服务器 Gind.cn

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

Apache中的系统错误与httpsredirect加上密码要求和错误文档的组合

在Apache 2虚拟主机中,我有以下configuration(在我的情况下,文档根目录的.htaccess (为简单起见,http:80和https:443也是如此) RewriteEngine On RewriteCond %{HTTPS} off RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} 为了将任何http连接redirect到https而且, ErrorDocument 500 /error.php ErrorDocument 404 /error.php ErrorDocument 403 /error.php ErrorDocument 402 /error.php ErrorDocument 401 /error.php 生成自定义错误消息。 第三个要素是一个受保护的子文件夹,需要进行身份validation(每个.htaccess在该文件夹中): AuthType Basic AuthName "Test" AuthUserFile /some/path/to/passwords Require user joe 一切工作正常,除非有人试图检索http://example.com/protectedfolder事实上,会发生什么事情是,客户端获得302 Found答复redirect到https://example.com/error.php 另一方面, 如预期的那样, https://example.com/protectedfolder会导致一个自定义(即,由error.php生成) 401 。 http://example.com/publicfolder导致302redirect到https://example.com/publicfolder ,然后301永久redirect到https://example.com/publicfolder/ ,最后(因为DirectoryIndex被禁用)a自定义403错误。 正如所料。 而且, http://example.com/nonexistent也会导致302到https://example.com/nonexistent ,然后按照预期的那样定制404 。 如果我禁用了ErrorDocument 401configuration,则http://example.com/protectedfolder的查询会立即生成401 […]