Page 1 of 1

Redirect root to a new domain

Posted: Wed Oct 13, 2010 4:38 am
by klevis miho
How can I redirect the the root of domain1.com to domain2.com/folder, but without changing the URL in the address bar (so after the redirection is done, domain1.com will be still there).

Re: Redirect root to a new domain

Posted: Wed Oct 13, 2010 10:28 am
by VladSun
Probably mod_rewrite could be a solution.

Re: Redirect root to a new domain

Posted: Wed Oct 13, 2010 10:29 am
by klevis miho
Yes, but how to? :)

Re: Redirect root to a new domain

Posted: Wed Oct 13, 2010 10:41 am
by VladSun
What have you tried so far :P ?

Re: Redirect root to a new domain

Posted: Wed Oct 13, 2010 10:50 am
by klevis miho
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.domain1\.com [NC]
RewriteRule ^(.*) http://domain2.com/$1 [R=301,L]

Re: Redirect root to a new domain

Posted: Wed Oct 13, 2010 1:10 pm
by John Cartwright
klevis miho wrote:How can I redirect the the root of domain1.com to domain2.com/folder, but without changing the URL in the address bar (so after the redirection is done, domain1.com will be still there).
This is not possible with mod_rewrite. There is a few hacks you could do to simulate the behavior, such as an iframe (simple), or proxy (complicated + slow).

Re: Redirect root to a new domain

Posted: Wed Oct 13, 2010 2:23 pm
by klevis miho
Or with some DNS trick?
Do you know how to do it with DNS?

Re: Redirect root to a new domain

Posted: Wed Oct 13, 2010 2:38 pm
by John Cartwright
I wouldn't know how to do it with a sub folder, but you can easily turn that into a subdomain, at which point you could do this.