WordPress Exclude Subdirectory

By default WordPress considers all files and directories from the installed directory to be under its control.

For a website I had installed WordPress in the root of the website file structure.

Subsequently I wished to install another program suite within a subdirectory.

I had no desire for files missing within this directory to be reported as a WordPress website 404 error.

To exclude the subdirectory called gallery from the WordPress website I added a rewrite condition to the..htaccess file within the root of the website.

RewriteCond %{REQUEST_URI} !^/?gallery

Giving:

# BEGIN WordPress
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/gallery
RewriteRule . /index.php [L]
# END WordPress

With the addition of an additional RewriteCond statement I was able to exclude a subdirectory from inclusion in the existing WordPress website.

References

https://www.sitepoint.com/community/t/ignore-a-folder-using-htaccess/4306

https://wordpress.org/support/topic/wp-20-htaccess-overly-aggressive-404s-galore/