How to exclude a folder from WordPress permalinks?

The default WordPress rewrite rules for permalinks might not work in some cases. For example, when you have other settings defined in .htaccess files located in subfolders.

To exclude the subfolders from the WordPress rewrite rules, you need to edit the .htaccess file and change the bold line below:

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

to

RewriteRule ./ /index.php [L]

If you want a lightning-fast WordPress website, check out our free eBook WordPress Speed Optimization Ebook! In it you will find a variety of easy-to-follow tips to improve the speed of your site!

2 Comments

  1. Reply January 13, 2016 / 13:54 Gary VanceSiteGround Team

    Perfect - this is exactly what I needed, thank you - nowhere else was this specific change mentioned - for info this is what I ended up with:

    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_URI} ^/mydir/(.*)$
    RewriteRule ^.*$ - [L]

    # BEGIN WordPress

    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ./ /index.php [L]

    # END WordPress

    • Reply January 14, 2016 / 12:59 Hristo PandjarovSiteGround Team

      Glad to help 🙂

* (Required)