I have to redirect all example.com to www.example.com except for instance.com/subdirectory that ought to remain out of the box with no redirection.

I've reduced the problem by getting the next within the .htaccess file

RewriteEngine On

RewriteCond $1 !^subdirectory RewriteCond % !^www.example.com$ [NC] RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]