If you've followed "Method I" on the WordPress help page you link to then you shouldn't actually need to do anything else. Your legacy folders are already excluded.
The solution they give is (.htaccess
in the root directory):
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?example.com$
RewriteCond %{REQUEST_URI} !^/my_subdir/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /my_subdir/$1
RewriteCond %{HTTP_HOST} ^(www.)?example.com$
RewriteRule ^(/)?$ my_subdir/index.php [L]
</IfModule>
This already excludes any existing files and directories from being rewritten. The two conditions that check against REQUEST_FILENAME
handle this. So, any legacy folders on your filesystem are already excluded.
The only thing that is not excluded is if you requested a non-existent file in a legacy folder. Currently that would be routed through WordPress and result in a WordPress generated 404. This is probably desirable I would think. However, if you wish to exclude any request to the legacy folder then you can add additional conditions to the above rule block...
RewriteCond %{REQUEST_URI} !^/my_subdir/
This specifically excludes any request that is already for the /my_subdir/
directory (ie. the directory that contains your WordPress installation). (Although this check is actually unnecessary if you have an additional .htaccess
file in the WordPress subdirectory and pretty permalinks enabled.). Simply repeat this condition for each legacy folder you wish to exclude:
RewriteCond %{REQUEST_URI} !^/\.well-known/
RewriteCond %{REQUEST_URI} !^/Music/
RewriteCond %{REQUEST_URI} !^/Rutabagas/
Explicitly excluding these folders in this way is actually more efficient, since it avoids the filesystem check that follows.
NB: The dot (.
) is a meta character in the regex and needs to be backslash escaped in order to match a literal dot only. The WordPress code sample above actually failed to do this...
RewriteCond %{HTTP_HOST} ^(www.)?example.com$
Should be:
RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$
Although, if you are on shared hosting and you only have 1 domain name, then this HTTP_HOST
check is redundant.