Exclude a path from WordPress using .htaccess redirects (Apache)

One small hiccup is that you’ll need to update RewriteRule ./ in that second to last line. Here is an updated (and tested) snippet for you:

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

# END WordPress

I tested both:

Hope that helps!!

Leave a Comment