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

I'm trying to redirect all the traffic from .se to .com but for some reason the VirtualHost ignores the ServerName and ServerAlias that I define.

<VirtualHost *:80>
    ServerName www.example.se
    ServerAlias example.se
    Redirect 301 / https://www.example.com/
</VirtualHost>

In the above example all the traffic will go through the VirtualHost redirect even though the tld is not .se

Am I missing something?

share|improve this question

1 Answer 1

up vote 4 down vote accepted

Short answer: Yes.

Long answer: It sounds like this is your first VirtualHost in the configuration file, which makes this the primary virtual host. It means that your other virtual hosts aren't specific enough to match the traffic, causing them to land in this virtual host instead.

Refer to the following page: http://httpd.apache.org/docs/2.2/vhosts/name-based.html

In particular:

Main host goes away

If you are adding virtual hosts to an existing web server, you must also create a block for the existing host. The ServerName and DocumentRoot included in this virtual host should be the same as the global ServerName and DocumentRoot. List this virtual host first in the configuration file so that it will act as the default host.

share|improve this answer
    
wow how fast to respond! and I was beginning a philosophical answer extra large :) +1 –  RTOSkit Jan 8 '13 at 1:00
1  
haha, I worked with httpd pretty constantly for a few years so I'm like a robot now. Maybe my avatar is a little too appropriate... –  Andrew B Jan 8 '13 at 1:04

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.