Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

We currently have an internal site set up for IT at it.example.com, which hosts a single Redmine site.

I want to set up Apache so that if a user goes to kb.example.com it redirects them to http://it.example.com/some/path/to/knowledge-base as a shortcut.

I added a <VirtualHost> at the end of my httpd.conf, and now whenever I try to hit the main site (it.example.com) the browser goes into an infinite redirection loop:

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

Here is my 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 support@example.com
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>

So it looks like the VirtualHost is being ignored and the rules for kb.example.com are ALWAYS in effect - thus causing the infinite redirect...

share|improve this question

1 Answer 1

up vote 6 down vote accepted

I think you need to wrap your existing it.example.com definition in a <VirtualHost> block. I think this is being caused because without the vhost definition for it.example.com, kb.example.com becomes the default vhost. In the event that a suitable vhost isn't found this is what will be served which then comes back to itself ...

share|improve this answer
    
This was it! Thanks! –  DOOManiac Apr 4 at 15:08

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.