This setup with the P
flag is the right one for what you want to do. The doc about the P flag states:
Use this flag (P) to achieve a more powerful implementation of the
ProxyPass directive
Some things about the example: as mentioned by Andrew in his answer, the DOCUMENT_ROOT
is not necessary.
The second is just to pay attention where these instructions are located: remove the first
"/" of the RewriteRule (^(.*)$) if you put this in a or similar container...
And the P flag implies the L flag, so it is not used but may make it a bit clearer if we leave it. There is also a "/" needed after the web addres.
So it may become something like:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^/(.*)$ http://somewhere/$1 [P,QSA,L]