'Wordpress generate_rewrite_rules is not working with multisite
Below is a sample of a few redirects we are using in our theme. They all work correctly in a standard install of WordPress but do not work in a multisite installation. Is there a special code we have to run to enable these rewrites in multisite.
We have tried adding the multisite slug to the rewrite without success.
add_filter( 'generate_rewrite_rules', function( $wp_rewrite ){
// Front End
$uri = str_replace(home_url(),'',get_stylesheet_directory_uri());
$uri = substr($uri,1); // remove trailing slash
// Back End
$adminuri = str_replace(home_url(),'',get_template_directory_uri());
$adminuri = substr($adminuri,1); // remove trailing slash
$feed_rules = array(
// FavIcon forward
$uri.'/favicon.ico' => 'index.php?favicon=$matches[1]',
// Fonts for Dev Mode
$uri.'/fonts/([^/]*)/([^/]*)/?$' => 'index.php?fontLoc=1&fontFace=$matches[1]&fontType=$matches[2]',
$uri.'/fontawesome/([^/]*)/([^/]*)/?$' => 'index.php?fontLoc=2&fontFace=$matches[1]&fontType=$matches[2]',
$adminuri.'/inc/css/fontawesome/([^/]*)/([^/]*)/?$' => 'index.php?fontLoc=2&fontFace=$matches[1]&fontType=$matches[2]',
// Sitemap Redirect
$uri.'/sitemap.xml' => $uri.'/wp-sitemap.xml'
);
$wp_rewrite->rules = $feed_rules + $wp_rewrite->rules;
return $wp_rewrite->rules;
});
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
