If you need to redirect a whole site to a new url except for one or more folders, then the script below will work for you.
When would you use this?
Let's say you have domainA.com and want to redirect everything to domainB.com but you are still hosting some images or pages that you still want/need to access on domainA.com
In the example below, we are redirecting ALL pages EXCEPT for anything in the folder: /clients/ and /wordpress/wp-content/uploads/
You see in the example below we are hosting a client billing section in /clients/ and we have images within the client section stored under the wordpress uploads folder.
So this allows the whole of the site to redirect to our new site but we still have access to some of the old assets.
RewriteEngine on RewriteCond %{REQUEST_URI} !^/clients/.* RewriteCond %{REQUEST_URI} !^/wordpress/wp-content/uploads/.* RewriteRule .* https://www.domainB.com [R=301,L]