iis7_save_url_rewrite_rules

函数
iis7_save_url_rewrite_rules ( No parameters )
返回值
  • (bool|null) True on write success, false on failure. Null in multisite.
定义位置
相关方法
iis7_add_rewrite_ruleiis7_delete_rewrite_rulesave_mod_rewrite_rulesiis7_rewrite_rule_existsadd_rewrite_rule
引入
2.8.0
弃用
-

iis7_save_url_rewrite_rules: 此函数保存IIS7服务器上的URL重写规则。

如果IIS的web.config文件是可写的,就用当前的规则更新它。

如果permalinks不需要重写规则,那么这些规则将从web.config文件中删除。

function iis7_save_url_rewrite_rules() {
	global $wp_rewrite;

	if ( is_multisite() ) {
		return;
	}

	// Ensure get_home_path() is declared.
	require_once ABSPATH . 'wp-admin/includes/file.php';

	$home_path       = get_home_path();
	$web_config_file = $home_path . 'web.config';

	// Using win_is_writable() instead of is_writable() because of a bug in Windows PHP.
	if ( iis7_supports_permalinks()
		&& ( ! file_exists( $web_config_file ) && win_is_writable( $home_path ) && $wp_rewrite->using_mod_rewrite_permalinks()
			|| win_is_writable( $web_config_file ) )
	) {
		$rule = $wp_rewrite->iis7_url_rewrite_rules( false );

		if ( ! empty( $rule ) ) {
			return iis7_add_rewrite_rule( $web_config_file, $rule );
		} else {
			return iis7_delete_rewrite_rule( $web_config_file );
		}
	}

	return false;
}

常见问题

FAQs
查看更多 >