Exclude Certain Folders from htaccess Rewrite Rules

Print View Mobile View

If you have an application or CMS running, you might have SEO url’s enabled through .htaccess rewrites. Now installing a second application in a subfolder on the same domain can cause 404 errors. This is because all subfolders follow the rules specified in the root htaccess file.

To prevent the errors, there is a single line which you can add to exclude such a foldername from being rewritten. Below a default .htaccess file for WordPress:

To prevent the errors, you can add the below single line to your rewrites to exclude that particular application folder.

RewriteCond %{REQUEST_URI} !^/(folder1|folder2/.*)$

Simply replace “folder1” with your own subfolder name that needs to be excluded from the rewrite.

In a default WordPress installation, it would look like this:

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^/(folder1|folder2/.*)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

One thought on “Exclude Certain Folders from htaccess Rewrite Rules”

Comments are closed.