How to Fix WordPress Multisite Redirect Loop Network Admin

So you’ve decided to try WordPress Multisite?

WordPress Multisite has its uses even though many people don’t usually recommend it.
It is probably because not many WordPress plugins are compatible with it.

You can use WordPress multisite for different subsections of the site. e.g. support, help, developer docs etc. i.e. everything that’s related to a product or a business goal.

The issue: When you go network admin it keeps redirecting. This is usually caused by current web path e.g. / and the database not matching. Another possible reason for having a redirect loop could be that the current domain does match what’s in the database.

We setup a development site which in a folder e.g. /projects/cool-project/app/site/
The site was previously a regular WordPress site and we converted it using WP-CLI command

wp core multisite-convert

It converted the site and updated its tables.

We had to update the current .htaccess file and before we did this we backed it up of course.

# BEGIN WordPress
RewriteEngine On
RewriteBase /projects/cool-project/app/site/
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 ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]
# END WordPress

wp-config was updated but because the multisite was in a directory it we had to update the PATH_CURRENT_SITE php const.

define( 'MULTISITE', true );
define( 'WP_ALLOW_MULTISITE', true );
define( 'SUBDOMAIN_INSTALL', false );

$base = '/';
define( 'DOMAIN_CURRENT_SITE', '' );
define( 'PATH_CURRENT_SITE', '/projects/cool-project/app/site/' );
define( 'SITE_ID_CURRENT_SITE', 1 );
define( 'BLOG_ID_CURRENT_SITE', 1 );

define( 'COOKIEPATH', '/projects/cool-project/app/site/' );
define( 'ADMIN_COOKIE_PATH', '/projects/cool-project/app/site/' );

It seems WordPress also needed the path for the main site to be updated as well.

You can run these commands via WP-CLI or phpMyAdmin or whatever db admin tool you’re using.

UPDATE `YOUR_DB_TABLE_PREFIX_site` SET `path` = '/projects/cool-project/app/site/' WHERE `id` = 1;

probably also too
UPDATE `YOUR_DB_TABLE_PREFIX_blogs` SET `path` = '/projects/cool-project/app/site/' WHERE `blog_id` = 1;

You can list the site’s info by running the following command.

wp site list

which should return something along these lines

| blog_id | url                                                                         | last_updated        | registered          |
| 1       |         | 0000-00-00 00:00:00 | 2024-03-02 08:44:09 |
| 3       | | 2024-03-02 09:14:33 | 2024-03-02 09:14:33 |

another user trying to solve this same issue.

Leave a Comment

Your email address will not be published. Required fields are marked *