WordPress Skeleton, VVV, Multisite, and the right Nginx rules
Just few notes:
Your wp-content/
folder isn't under the wp/
folder as you stated here:
rewrite ^/(wp-(content|admin|includes).*) /wp/$1 last;
Since default themes, like Twenty Fifteen come shipped with the /wp/wp-content/
folder, it could explain why you get it to work there.
Regarding the missing /wp/
part in the network admin urls, Daniel Bachhuber has posted this handy gist snippet that fixes that problem. It uses the network_site_url
filter to inject it.
<?php/** * Fix network admin URL to include the "/wp/" base * * @see https://core.trac.wordpress.org/ticket/23221 */add_filter( 'network_site_url', function( $url, $path, $scheme ){ $urls_to_fix = array( '/wp-admin/network/', '/wp-login.php', '/wp-activate.php', '/wp-signup.php', ); foreach( $urls_to_fix as $maybe_fix_url ) { $fixed_wp_url = '/wp' . $maybe_fix_url; if ( false !== stripos( $url, $maybe_fix_url ) && false === stripos( $url, $fixed_wp_url ) ) { $url = str_replace( $maybe_fix_url, $fixed_wp_url, $url ); } } return $url;}, 10, 3 );
Also see the open ticket #23221 on Multisite in subdirectory with root site address
Some discussions here on GitHub regarding nginx + multisite with wp-skeleton structure (I posted there some experiments some time ago).
Consider a solution just with updated NGINX config, which I've published on github.Change your rewrites with following
if (!-e $request_filename) { rewrite ^/(wp-admin/.*)$ /wp/$1 last; rewrite ^/[_0-9a-zA-Z-]+(/wp-admin/.*)$ /wp/$1 last; rewrite /wp-admin$ $scheme://$host$uri/ permanent; rewrite ^/[_0-9a-zA-Z-]+(/wp-includes/.*) /wp/$1 last; rewrite ^/(wp-[^/]+\.php)$ /wp/$1 last; rewrite ^/[_0-9a-zA-Z-]+(/wp-.*) $1 last; rewrite ^/[_0-9a-zA-Z-]+(/.*\.php)$ $1 last;}rewrite ^/(wp-includes/.*)$ /wp/$1 last;
That will solve all the problems with access to admin panels and the network admin panel with sub-folder installation of the Wordpress Multisite. No need code writing.