Excluding Directories From Rewrite Rules

A client who hosts their own website recently launched a new version of their site, which had been developed in WordPress instead of the static html site they had before. However, they used their web space to host multiple applications in subdirectories on the domain. This was going to cause problems with WordPress and it’s rewrite rules, since the permalinks may have conflicted with the names of the physical directories where the other applications lived.

For most people’s WordPress installations running on a *nix platform, you would need to go into the .htaccess file and insert this RewriteRule above all other rules.

However, this client was hosting their site using Windows so we needed to figure out a way to make the same change under IIS, using the web.config file instead. After some digging and testing, we found it only takes a single additional line to add exclusions to the rewrite rules. Here is the full web.config file after modification.

With that one {REQUEST_URI} line, you can pipe-delimit all of the top-level directory names that you wish to exclude from the rewrite rules with IIS.

Hopefully this post helps someone else with the same problem!

Leave a Reply