'htaccess rewrite domain to subfolder including subfolders

My folder structure is:

- olddomain.com
- olddomain.com/folderA
- olddomain.com/folderA/subfolderA
- olddomain.com/folderB

I have a new domain name, and I want to point it to folderA. So far so good, in the browser "newdomain.com" takes me to "olddomain.com/folderA" without showing it in the URL (user always sees newdomain.com), which is what I want.

But in the browser "newdomain.com/subfolderA/" takes me to a 404 page, instead to "olddomain.com/folderA/subfolderA/". Any ideas how to include in the rewrite all subfolders and keep the url structure?

This is my .htaccess code so far.

RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?newdomain.com$
RewriteCond %{REQUEST_URI} !^/folderA/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /folderA/$1
RewriteCond %{HTTP_HOST} ^(www.)?newdomain.com$
RewriteRule ^(/)?$ folderA/index.html [L]


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source