Exclude folder / directory from RewriteRule

I have a pretty standard WordPress.htaccess with the following URL rewrites

# BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress 

WordPress is installed in my domain root. I have other scripts in subfolders, for example. / opencart These subfolders contain their own .htaccess files.

Unfortunately, it seems that WordPress sometimes captures rewrites for some of these scripts.

How can I ask mod_rewrite to ignore WordPress rules for rewriting when detected in certain subfolders, for example. opencart and use the rules defined in .htaccess in these subfolders?

+6
source share
3 answers

You can try replacing the full set of WP rules with this:

 # BEGIN WordPress RewriteEngine On RewriteBase / RewriteRule ^index.php$ - [L] # Include in the next line all folders to exclude RewriteCond %{REQUEST_URI} !(folder1|folder2|folder3) [NC] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] # END WordPress 
+19
source

In the .htaccess file at the root of your site, add the following ABOVE WordPress .htaccess directives:

 <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{REQUEST_URI} ^/subdirectoryname1/(.*)$ [OR] RewriteCond %{REQUEST_URI} ^/subdirectoryname2/(.*)$ [OR] RewriteRule ^.*$ - [L] </IfModule> 
+5
source
 # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteRule ^/(folder1)/(.*) /folder1/$2 [R] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L,R] </IfModule> # END WordPress 
-1
source

All Articles