为什么我的 Apache 陷入了无限重定向循环?

为什么我的 Apache 陷入了无限重定向循环?

我们目前已为 IT 部门设立了一个内部网站it.example.com,其中包含一个Redmine地点。

我想设置 Apache,以便当用户访问kb.example.com它时,将其重定向到http://it.example.com/some/path/to/knowledge-base快捷方式。

<VirtualHost>在 httpd.conf 末尾添加了一个,现在每当我尝试访问主站点(it.example.com)时,浏览器就会进入无限重定向循环:

http://it.example.com/projects/knowledge-baseprojects/knowledge-baseprojects/knowledge-baseprojects/knowledge-baseprojects/knowledge-baseprojects/knowledge-baseprojects/knowledge-baseprojects/knowledge-baseprojects/knowledge-baseprojects/knowledge-baseprojects/knowledge-baseprojects/knowledge-baseprojects/knowledge-baseprojects/knowledge-baseprojects/knowledge-baseprojects/knowledge-baseprojects/knowledge-baseprojects/knowledge-baseprojects/knowledge-baseprojects/knowledge-base

这是我的httpd.conf

LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-4.0.37/buildout/apache2/mod_passenger.so
<IfModule mod_passenger.c>
  PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-4.0.37
  PassengerDefaultRuby /usr/bin/ruby
</IfModule>

ServerName it.example.com
ServerAdmin [email protected]
DocumentRoot /var/www/redmine-2.4.3/public
ErrorLog logs/redmine_error_log
SetEnv RAILS_ENV production
SetEnv RailsEnv production

#If you are using mod_fcgid and are going to upload files larger than
 #131072 bytes you should consider adding the following line
#that allows to upload files up to 20 mb
MaxRequestLen 20971520

<Directory "/var/www/redmine-2.4.3/public">
    Options Indexes ExecCGI FollowSymLinks -MultiViews
    Order allow,deny
    Allow from all
    AllowOverride all
</Directory>

<VirtualHost *:80>
  ServerName kb.example.com
  Redirect / http://it.example.com/projects/knowledge-base
</VirtualHost>

因此看起来 VirtualHost 被忽略了,而 kb.example.com 的规则始终有效 - 从而导致无限重定向...

答案1

我认为您需要将现有的it.example.com定义包装在一个<VirtualHost>块中。我认为这是因为没有 vhost 定义it.example.comkb.example.com将成为默认 vhost。如果找不到合适的 vhost,那么将提供此服务,然后返回自身...

相关内容