How to exclude a directory from WordPress permalinks in a Multisite environment?

This “exception” would only be required if you are requesting virtual URLs within /folderToExclude, as opposed to physical files. Any requests to physical directories and files are naturally excluded by the standard WordPress directives.

RewriteCond %{REQUEST_URI} !^/(folderToExclude/.*)$

# add a trailing slash to /wp-admin
RewriteRule ^wp-admin$ wp-admin/ [R=301,L]

This condition (RewriteCond directive) won’t do anything where you’ve put it. RewriteCond directives don’t do anything by themselves, they apply to the first RewriteRule directive that follows. In this case, the above rule is checking that the request URL-path matches /wp-admin and does not start /foldertoExclude/ – the condition is always successful (if A=B then A!=C), so is not doing anything.

However, as written, you couldn’t place that condition on the later rule either since the logic is reversed. (Maybe you’ve used this in the past on a single-site WordPress install?)

Remove that RewriteCond directive entirely.

Rather than modifying the WordPress code block you should create an additional rule before the # BEGIN WordPress section, to exclude all requests that start /folderToExclude from being processed at all by the WordPress directives.

For example:

# Exclude specific directories
RewriteRule ^folderToExclude($|/) - [L]

# BEGIN WordPress
:

No need to repeat the RewriteEngine directive. No other RewriteCond directives are necessary.

An alternative is to create another .htaccess file in the /folderToExclude directive with a single RewriteEngine Off (or On) directive. This will then override the WordPress mod_rewrite directives in the parent .htaccess file.