On IIS, stop WordPress from resaving my web.config file when I enter the Permalinks config page

You can prevent a “hard” flush, which updates .htaccess (Apache) or web.config (IIS), with the flush_rewrite_rules_hard filter.

We can also use the __return_false helper function here.

add_filter( 'flush_rewrite_rules_hard', '__return_false' );

This code can be placed in your own plugin or a theme’s functions.php file.