Bedrock multisite not playing nice with Gutenberg

Hi all,

I have a subdomain multisite setup using Bedrock, but I’m running into problems managing pages.

I installed one of the forks of the multisite-url-fixer, and removed the /wp bit from WP_HOME and WP_SITEURL in wp_options (and in the .env, though that shouldn’t matter). This fixed the front-end, so that’s good. However, when I want to edit a page, I get an endless stream of 403 errors on various API calls it tries to do.

What’s weird is that I noticed the URLs for managing pages still contain the /wp part (no idea where it gets it from), and when I manually remove that from the URL (from /wp/wp-admin/post.php?post=23&action=edit to /wp-admin/post.php?post=23&action=edit for example), updating pages works just fine. So I’m guessing I’m missing some important redirect rule?

My .htaccess looks like this (taken from documentation on the subject):

RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]

# add a trailing slash to /wp-admin
RewriteRule ^wp-admin$ wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(wp-(content|admin|includes).*) wp/$1 [L]
RewriteRule ^(.*\.php)$ wp/$1 [L]
RewriteRule . index.php [L]

Since I didn’t do anything fancy with this setup, I imagine many people have ran into this problem. I there a known fix? If so, I’d love to hear about it.

Kind regards,

ACJ

Maybe I’m misunderstanding what you’re doing/have done, but GitHub - owlsdepartment/multisite-url-fixer: Fixes WordPress issues with home and site URL on multisite when using Bedrock seems to be explicitly adding /wp to the site and network site URLS unless you’ve defined WP_BASE—so what you’re describing is the behavior I would expect. (Not the 403s, but the URLs you’re seeing.)

1 Like

The problem is not that wp-admin has /wp/ in front of it. The problem is the 403s that render the admin useless. If I manually remove said /wp/ part from the URL, the admin still works, and without the 403s.

1 Like

What’s your Bedrock config look like for the multisite settings?

Also:

The multipart section of my application.php looks like this:

Config::define('WP_ALLOW_MULTISITE', true);
Config::define('MULTISITE', true);
Config::define('SUBDOMAIN_INSTALL', true); // Set to true if using subdomains
Config::define('DOMAIN_CURRENT_SITE', env('DOMAIN_CURRENT_SITE'));
Config::define('PATH_CURRENT_SITE', env('PATH_CURRENT_SITE') ?: '/');
Config::define('SITE_ID_CURRENT_SITE', env('SITE_ID_CURRENT_SITE') ?: 1);
Config::define('BLOG_ID_CURRENT_SITE', env('BLOG_ID_CURRENT_SITE') ?: 1);
Config::define('ADMIN_COOKIE_PATH', '/');
Config::define('COOKIE_DOMAIN', '');
Config::define('COOKIEPATH', '');
Config::define('SITECOOKIEPATH', '');

…with one .env having:

WP_HOME='https://dutchsummerenbeauty.depreview.nl'
WP_SITEURL="${WP_HOME}"
DOMAIN_CURRENT_SITE='dutchsummerenbeauty.depreview.nl'

…and the other having:

WP_HOME='https://dutchcleaningservice.depreview.nl'
WP_SITEURL="${WP_HOME}"
DOMAIN_CURRENT_SITE='dutchcleaningservice.depreview.nl'

I modified the wp_options records to reflect these values.

The relevant portion of the .htaccess reads:

RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]

# add a trailing slash to /wp-admin
RewriteRule ^wp-admin$ wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(wp-(content|admin|includes).*) wp/$1 [L]
RewriteRule ^(.*\.php)$ wp/$1 [L]
RewriteRule . index.php [L]

The thread you linked to does mention the same issue that I encounter, which is interesting, but it seems to die silently without coming to a clear solution.

The topic I linked has a solution, and the config you provided is missing it. Try setting the cookie domain per the solution in that topic.

I saw the config, but the OP of that topic then went on to comment that it did not work after all, implying there is more to it. Anyway, I will add the config and report back. Thanks for your help!

No luck. Adding the config changed nothing in my setup. Still getting the 403 errors.

I removed the multisite-url-fixer from my setup and now everything seems to be working fine. I don’t understand why it wasn’t working before and how I ended up in this rabbit hole, but at last I continue my work. Thanks for the help and patience.

1 Like