0

This is for a multisite that has 3 levels of organization: main site - regions (subsites) and locations (sub-subsites). So you would be able to visit and administrate these urls:

domain.com --> main site domain.com/region --> sub site domain.com/region/location --> sub-sub site

Both front and back end are getting loading errors in the Inspect Console because the path to the files in "wp-includes" and "wp-admin" are wrong.

I have sunrise.php activated.

These are the lines I added to wp-config.php:

/* Multisite */
define( 'WP_ALLOW_MULTISITE', true );
define('MULTISITE', true);
define('SUBDOMAIN_INSTALL', false);
define('DOMAIN_CURRENT_SITE', 'MY-DOMAIN'); // <- my real domain there
define('PATH_CURRENT_SITE', '/');
define('SITE_ID_CURRENT_SITE', 1);
define('BLOG_ID_CURRENT_SITE', 1);

define("WP_CONTENT_URL", "/wp-content");

define('ADMIN_COOKIE_PATH', '/');
define('COOKIE_DOMAIN', '');
define('COOKIEPATH', '');
define('SITECOOKIEPATH', '');

// Activate sunrise script
  define('SUNRISE', TRUE);
// define('WP_ALLOW_REPAIR', true);

This is my .htaccess file:

# BEGIN WordPress
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]

# uploaded files
RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]

# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]

# RewriteRule  ^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)+(wp-(content|admin|includes).*) $2 [L]

RewriteRule ^[_0-9a-zA-Z-]+/(.*\.php)$ $1 [L]
# RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]

RewriteRule . index.php [L]
# END WordPress

This is my sunrise.php file

id = (defined( 'SITE_ID_CURRENT_SITE' ) ? constant('SITE_ID_CURRENT_SITE') : 1); $current_site->domain = $domain = DOMAIN_CURRENT_SITE; $current_site->path = $path = PATH_CURRENT_SITE; if( defined( 'BLOGID_CURRENT_SITE' ) ) $current_site->blog_id = BLOGID_CURRENT_SITE; $url = parse_url( $_SERVER['REQUEST_URI'], PHP_URL_PATH ); $patharray = (array) explode( '/', trim( $url, '/' )); $blogsearch = ''; if( count( $patharray )){ foreach( $patharray as $pathpart ){ $pathsearch .= '/'. $pathpart; $blogsearch .= $wpdb->prepare(" OR (domain = %s AND path = %s) ", $domain, $pathsearch .'/' ); } } $current_blog = $wpdb->get_row( $wpdb->prepare("SELECT *, LENGTH( path ) as pathlen FROM $wpdb->blogs WHERE domain = %s AND path = '/'", $domain, $path) . $blogsearch .'ORDER BY pathlen DESC LIMIT 1'); $blog_id = $current_blog->blog_id; $public = $current_blog->public; $site_id = $current_blog->site_id; $current_site = pu_get_current_site_name( $current_site ); } function pu_get_current_site_name( $current_site ) { global $wpdb; $current_site->site_name = wp_cache_get( $current_site->id . ':current_site_name', "site-options" ); if ( !$current_site->site_name ) { $current_site->site_name = $wpdb->get_var( $wpdb->prepare( "SELECT meta_value FROM $wpdb->sitemeta WHERE site_id = %d AND meta_key = 'site_name'", $current_site->id ) ); if( $current_site->site_name == null ) $current_site->site_name = ucfirst( $current_site->domain ); wp_cache_set( $current_site->id . ':current_site_name', $current_site->site_name, 'site-options'); } return $current_site; } ?>
3
  • Wow, things have changed since I last did that. What have you put in your sunrise.php? What are the wrong paths you're seeing in the browser debug console? Can you work out where they're coming from? Can you work out what they should be, i.e. find an URL that works for the files it's not loading?
    – Rup
    Dec 18 '19 at 23:09
  • The errors I'm getting are on the Inspect console when not finding the file because of the wrong path. Like this: GET xxxxxxx.xxx/location/wp-includes/js/dist/a11y.min.js?ver=2.5.1 net::ERR_ABORTED 404 Just added the sunrise.php to the post.
    – Alvaro
    Dec 19 '19 at 15:37
  • That's the sunrise.php from here? gist.github.com/mhawksey/49f03991119c465cc33a I didn't think you needed to do that anymore since a few WordPress versions ago. Where did /location/ come from? Is that an URL you'd expect to work and isn't working, or is that the wrong URL for wp-includes?
    – Rup
    Dec 19 '19 at 17:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.