Redirect root (and only root) URL to another domain?

.htaccess, dns, redirect

Solution

Don't know if you still have this issue, but I have had it on one of my domains (Yourls installation). Try:

RewriteEngine On
RewriteRule ^$ http://www.example.com/ [R=301,L]

It works on my installation, but check it out on your site.

Problem

I'm looking to redirect my domain example.com and www.example.com to http://example2.com, but I want to keep all visits to my posts at http://example.com/sdfhs to continue through to their destinations. Essentially, I ONLY want to redirect the root and www domain and leave the rest untouched. How can I do this with .htaccess?

Original source