Exclude file/folder from Wordpress/Ghost rewrite

In your .htaccess file you might have a rule which ensures that all files and folders matching a particular path be handled by Wordpress or Ghost. An example of such a rule would be the following snippet:

RewriteCond %{REQUEST_URI} !^/(contact.php)$
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^(.*)$ http://your-domain.com:62914/$1 [P]

The following part of the snippet in the .htaccess file ensures that the contact.php file is excluded from the rewrite rule:

RewriteCond %{REQUEST_URI} !^/(contact.php)$

This is particularly useful when you need to exclude a file from being "managed" by Wordpress, Ghost or any other CMS for that matter.

To exlcude a whole folder as well as all files therein, the top rewrite condition from the snippet above will look as follows:

RewriteCond %{REQUEST_URI} !^/(YOUR-DIRECTORY|YOUR-DIRECTORY/.*)$