.htaccess – masking url using htaccess gives a 404

I have the following problem I am setting up a company whose domain and email is hosted by a local hosting company that I have used for years. In general, there are no problems, since the content of the website is also usually hosted on their servers. for this new project, the content of the website will actually be on a different server (I am paying for a managed website, so the content will be on the servers of that administration company). I want to keep my hosting as it is (especially due to email hosting) and use a URL masking to redirect website traffic to the other server without the user noticing …

I tried to achieve this with a htaccess and mod_rewrite:

RewriteEngine in
RewriteCond% {HTTP_HOST} ^ www.domainA.com
RewriteRule ^ (. *) Http://www.domainB.com [P]

but get the following 404:

Lost

The requested URL / was not found on this server.

Additionally, a 404 error was found when trying to use an ErrorDocument to handle the request.

It seems that it is the [P] in the htaccess configuration that the server does not like when I use other settings in the [] it works (but the URL is changed so that it is not masked).

Any idea what is happening here and how to achieve what I need?

Thank you very much in advance
Miguel