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 know that this question comes up often, I followed many examples and suggestions, but i just cant get it to work. Heres what I need to achieve:

I have two configure two domains to redirect to subdomain of one of them: domain-one.com (and www.domain-one.com) and domain-two.com should all send 301 Moved Permamently header and redirect to www.domain-two.com.

I've set up NamedVirtualHost for domain-one.com as follows:

ServerName domain-one.com
ServerAlias www.domain-one.com
Redirect 301 ^/ http://www.domain-two.com

And that seems to work for domain-one.com but www.domain-one.com does not redirect, whole setup seems to be ignored and files from server's default host configuration setup are served.

As for redirecting from domain-two.com to www.domain-two.com I created two NamedVirtualHosts, www.domain-two.com is the actual site with its configuration (ServerName set to www.domain-two.com) and domain-one.com is configured with this:

ServerName domain-two.com 
Redirect 301 ^/ http://www.domain-two.com

And this configuration also fails.

From what I read about redirecting within Apache Redirect directive should be sufficient to achieve what I need. I could use some mod_rewriting or even use PHP and appropriated headers() to do what I want, but can someone please explain to me what is wrong with my thinking and this configuration.

Thanks

share|improve this question

1 Answer 1

Try

Redirect permanent /(.*) http://www.domain-two.com/$1

Incase you don't want to append the request to the domain then you can do

Redirect permanent /(.*) http://www.domain-two.com
share|improve this answer

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.