htaccess disable WordPress rewrite rules for folder and its contents

The default .htaccess-file will already support the behaviour you want;

# 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

The magic is in the lines that start with RewriteCond. They instruct Apache to apply the rule RewriteRule . /index.php [L] (which means “any URL will go to index.php”), only when the URL is not an existing file !-f or existing directory !-d.

So this should work by default. The WordPress rewrite rules do not apply when you try to visit an already existing file.

Leave a Comment