.htaccess RewriteCond excluding directories does not work when there is an .htaccess or php.ini in subdirectory

You can try adding RewriteEngine On to the top of the subdirectory .htaccess file. This will have the effect of completely overriding the mod_rewrite directives in the parent (ie. WordPress) .htaccess file, because mod_rewrite directives are not inherited by default.

So by enabling the rewrite engine in the subdirectory, the WordPress front-controller will not execute (by default).

UPDATE:

I’m trying to access a folder inside public_html called “orden2” so the url is the following (example, not actual domain) www.example.com/orden2

Note that if you don’t specify a trailing slash when requesting a physical directory then mod_dir issues an 301 redirect to append the slash. mod_dir then makes an internal subrequest for the DirectoryIndex. If the DirectoryIndex is set to a fixed URL-path eg. /index.php instead of a relative path like index.php then the WordPress index.php in the document root will always be triggered.

You can try setting the DirectoryIndex in the root .htaccess file, before all the WordPress directives (ie. before # BEGIN WordPress). For example:

DirectoryIndex index.php

Another thing you can try (although this should be unnecessary) is to explicitly make an exception for your subdirectory in the WordPress .htaccess file. This should also go before the existing directives – at the very top of the file. For example:

# Explicitly exclude some URL-paths
RewriteRule ^orden2 - [L]