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.