save_mod_rewrite_rules()
The function updates the .htaccess file if it is writable. It removes old rules and adds new ones.
The function is triggered on each call of the function flush_rewrite_rules() when the first parameter = true (this is the default). Therefore, it usually does not need to be called separately.
Does not work for multisite - the check is performed by the function is_multisite().
Will only work on an Apache server with the mod_rewrite module loaded - the check is performed by the function got_mod_rewrite().
No Hooks.
Returns
true|false|null. Nothing (null).
Usage
save_mod_rewrite_rules();
Examples
#1 Disable the .htaccess update
By default when flush_rewrite_rules() is called, save_mod_rewrite_rules() is triggered. If we don't need this behavior, we can disable it with flush_rewrite_rules_hard hook:
add_filter( 'flush_rewrite_rules_hard', '__return_false' );
Notes
- Global. WP_Rewrite.
$wp_rewriteWordPress rewrite component.
Changelog
| Since 1.5.0 | Introduced. |