服务器 Gind.cn

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

apache2 defaultsiteredirect但不是虚拟主机

我试图build立一个新的服务器与几个虚拟主机,但也如此,如果请求的fqdn不匹配虚拟主机,然后请求被redirect到http://example.com/log.php?url=fqdn 我已经得到了默认的主机redirect,但我定义的虚拟主机不起作用。 我正在使用不同的主机进行testing,并在命令行上使用curl -I http://hostname.example.com:8080/来读取html头文件,以直接检查redirect头,而不是使用浏览器跟踪(避免任何caching问题)。 我已经定义了一个虚拟主机作为服务器的fqdn,但是当我使用curl来请求该虚拟主机时,我得到了redirect。 如果我通过没有定义虚拟主机的其他名称来请求服务器,我也会被redirect。 ubuntu上的apache版本是2.2.16 configuration(从几个不同的文件按顺序连接在一起)如下所示: Listen 8080 NameVirtualHost * <VirtualHost _default_> ServerAdmin [email protected] RewriteEngine On RewriteRule ^(.*)$ http://example.com/log.php?url=%{HTTP_HOST}$1 [R=302,L] </VirtualHost> <VirtualHost *> <Directory "/var/www"> allow from all Options Indexes </Directory> DocumentRoot /var/www ServerName hostname.example.com </VirtualHost> 我也尝试了hostname.example.com:*和hostname.example.com:8080的ServerName值 如果我不够清楚: anything.anything.anything.any / something requests from my server should redirect to example.com/log.php?url=anything.anything.any/something 从我的服务器请求的foo.example.com(未定义为VirtualHost)应该redirect到example.com/log.php?url=foo.example.com hostname.example.com(定义为VirtualHost)从我的服务器请求应该返回一个HTML文档 从我的服务器请求的anothername.example.com(也定义为VirtualHost)应该返回一个html文档 […]