.htaccess 301 redirect WHOLE WordPress site EXCEPT root domain

I have been searching around and I couldn’t find the following.
I was wondering if it is possible to redirect my whole WordPress blog to a new domain except for the root or homepage itself.
Any push in the right direction would be great. I hope I’m not asking a silly question here!

Thanks in advance for anyone who has the time to look at my question.

Related posts

Leave a Reply

1 comment

  1. Yes you can, try this code :

    RewriteEngine on
    
    RewriteRule ^(index.php)?$ - [L]
    
    RewriteCond %{HTTP_HOST} ^(www.)?olddomain.com$ [NC]
    RewriteRule ^(.+)$ http://www.newdomain.com/$1 [R=301,QSA,L]