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.

Is it possible to redirect domain names which already point to the same server?

For example, if my main website is www.companyname.com, and I have another domainname as www.companyname2.com, if I go to www.companyname2.com, I don't want users to see that domainname, I want them to be redirected to www.companyname.com, even though they both are the same website.

I am using RedHat linux and have a LAMP configuration.

share|improve this question

1 Answer 1

up vote 1 down vote accepted

Sure, you can do it like this:

<VirtualHost *:80>
ServerName www.companyname2.com
ServerAlias companyname2.com 
Redirect permanent / http://www.companyname.com/
</VirtualHost>
share|improve this answer
    
Do I need to restart apache after making this change? –  oshirowanen Apr 5 '11 at 9:15
    
Yes, I had to restart apache, but the script above puts the website into an infinite loop. –  oshirowanen Apr 5 '11 at 9:26
    
What does your access log say is happening? –  BillThor Apr 5 '11 at 13:25

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.