Example sunrise.php file for nested sub directories as described in https://paulund.co.uk/wordpress-multisite-with-nested-folder-paths, I used this on WordPress Multisite v.5.3.2, this is example for local setup, video description YouTube
# The directives (lines) between `BEGIN WordPress` and `END WordPress` are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [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 ^(.+)?(wp-(content|admin|includes).*) /$2 [L]
#RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]
</IfModule>
# END WordPress
<?php
/**
* The base configuration for WordPress
*
* The wp-config.php creation script uses this file during the
* installation. You don't have to use the web site, you can
* copy this file to "wp-config.php" and fill in the values.
*
* This file contains the following configurations:
*
* * MySQL settings
* * Secret keys
* * Database table prefix
* * ABSPATH
*
* @link https://codex.wordpress.org/Editing_wp-config.php
*
* @package WordPress
*/
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define( 'DB_NAME', 'wordpress');
/** MySQL database username */
define( 'DB_USER', 'wordpress');
/** MySQL database password */
define( 'DB_PASSWORD', 'wordpress');
/** MySQL hostname */
define( 'DB_HOST', 'db:3306');
/** Database Charset to use in creating database tables. */
define( 'DB_CHARSET', 'utf8');
/** The Database Collate type. Don't change this if in doubt. */
define( 'DB_COLLATE', '');
/**#@+
* Authentication Unique Keys and Salts.
*
* Change these to different unique phrases!
* You can generate these using the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}
* You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again.
*
* @since 2.6.0
*/
define( 'AUTH_KEY', '28220c3e390eabbe7bd95e1655dace2f88f195fa');
define( 'SECURE_AUTH_KEY', 'ecb80157003dd3ee4a2c5371b0a4f3998ee0ba32');
define( 'LOGGED_IN_KEY', '78b34556f7c41d3a5d3d99d412ac037ebb1cffce');
define( 'NONCE_KEY', 'f5c51b97d3bdb90ff200bb89c79d782709907082');
define( 'AUTH_SALT', 'f9ad75b1325019bd0cfc29427d77f1c44f048f5d');
define( 'SECURE_AUTH_SALT', 'e4ebf6b3ffb587079553b184fd14b8ac1564d578');
define( 'LOGGED_IN_SALT', 'a326a9b1a5fa598abfdcd6cdc15f53961d0a5335');
define( 'NONCE_SALT', 'ad1ebdbdcc5f3522109e17ead5c466769f9cc1f9');
/**#@-*/
/**
* WordPress Database Table prefix.
*
* You can have multiple installations in one database if you give each
* a unique prefix. Only numbers, letters, and underscores please!
*/
$table_prefix = 'wp_';
/**
* For developers: WordPress debugging mode.
*
* Change this to true to enable the display of notices during development.
* It is strongly recommended that plugin and theme developers use WP_DEBUG
* in their development environments.
*
* For information on other constants that can be used for debugging,
* visit the Codex.
*
* @link https://codex.wordpress.org/Debugging_in_WordPress
*/
define( 'WP_DEBUG', false );
// If we're behind a proxy server and using HTTPS, we need to alert WordPress of that fact
// see also http://codex.wordpress.org/Administration_Over_SSL#Using_a_Reverse_Proxy
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') {
$_SERVER['HTTPS'] = 'on';
}
define( 'WP_ALLOW_MULTISITE', true );
define('MULTISITE', true);
define('SUBDOMAIN_INSTALL', false);
define('DOMAIN_CURRENT_SITE', 'localhost');
define('PATH_CURRENT_SITE', '/');
define('SITE_ID_CURRENT_SITE', 1);
define('BLOG_ID_CURRENT_SITE', 1);
define('SUNRISE', TRUE);
/* That's all, stop editing! Happy publishing. */
/** Absolute path to the WordPress directory. */
if ( ! defined( 'ABSPATH' ) ) {
define( 'ABSPATH', dirname( __FILE__ ) . '/' );
}
/** Sets up WordPress vars and included files. */
require_once( ABSPATH . 'wp-settings.php' );
<?php
if( defined( 'DOMAIN_CURRENT_SITE' ) && defined( 'PATH_CURRENT_SITE' ) ) {
$current_site->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;
}
?>