Advertisements

save_mod_rewrite_rules

Definition:
function save_mod_rewrite_rules() {}

Updates the htaccess file with the current rules if it is writable.
Always writes to the file if it exists and is writable to ensure that we blank out old rules.

Source code

function save_mod_rewrite_rules() {

	if ( is_multisite() )

		return;



	global $wp_rewrite;



	$home_path = get_home_path();

	$htaccess_file = $home_path.'.htaccess';



	// If the file doesn't already exist check for write access to the directory and whether we have some rules.

	// else check for write access to the file.

	if ((!file_exists($htaccess_file) && is_writable($home_path) && $wp_rewrite->using_mod_rewrite_permalinks()) || is_writable($htaccess_file)) {

		if ( got_mod_rewrite() ) {

			$rules = explode( "\n", $wp_rewrite->mod_rewrite_rules() );

			return insert_with_markers( $htaccess_file, 'WordPress', $rules );

		}

	}



	return false;

}

2805

Advertisements

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: