$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>Multisite network admin – URLredirect error|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

Multisite network admin – URLredirect error

matteradmin8PV0评论

I followed this guide on how to set up a WordPress installation that is optimized for git deployment.

Basically, WordPress is moved into a subfolder called wordpress, index.php and wp-config.php are moved out of the subfolder, as well as wp-content.
To make that work, the path to wp-blog-header.php is adjusted, as well as the path to to wp-content.

I had this working without problems with a single site installation, but since I often have to work with multisites, I tried to create one.

Besides the warning Warning! Subdirectory networks may not be fully compatible with custom wp-content directories. everything worked as usual, with one problem:

I can't access the network admin screens.

The site admin URL look like this: /wordpress/wp-admin/, but the links to the network admin look like this: /wp-admin/network/sites.php.
So you see, the /wordpress/ is missing. If I add in manually, the network admin screens load as expected.

My .htaccess looks like this:

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

and the relevant parts of my wp-config.php look like this:

define( 'WP_ALLOW_MULTISITE', true );

define('MULTISITE', true);
define('SUBDOMAIN_INSTALL', false);
define('DOMAIN_CURRENT_SITE', 'local.dev');
define('PATH_CURRENT_SITE', '/');
define('SITE_ID_CURRENT_SITE', 1);
define('BLOG_ID_CURRENT_SITE', 1);

I already tried to change PATH_CURRENT_SITE from /to /wordpress/.
That fixes the url, but the network admin screen won't load because there are too many redirects, so it seems that the problem is in my .htaccess.

There I already tried this (as suggested here), but this does not solve the problem – the same error persists:

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

WordPress version is 4.0, the network was also started at this version.

Do you see whats wrong with this setup? How do I fix the 'too many redirects' error?

Edit: I investigated the issue a bit further. I tried to do the same with a single site installation and it worked without problems. My guess is that the warning message I quoted is there for a reason. Still, I would love to know if there is a fix or workaround for this. Also, I am now pretty sure that PATH_CURRENT_SITE must be /, which means it's clearly an .htaccess issue.

I followed this guide on how to set up a WordPress installation that is optimized for git deployment.

Basically, WordPress is moved into a subfolder called wordpress, index.php and wp-config.php are moved out of the subfolder, as well as wp-content.
To make that work, the path to wp-blog-header.php is adjusted, as well as the path to to wp-content.

I had this working without problems with a single site installation, but since I often have to work with multisites, I tried to create one.

Besides the warning Warning! Subdirectory networks may not be fully compatible with custom wp-content directories. everything worked as usual, with one problem:

I can't access the network admin screens.

The site admin URL look like this: http://local.dev/wordpress/wp-admin/, but the links to the network admin look like this: http://wp1.dev/wp-admin/network/sites.php.
So you see, the /wordpress/ is missing. If I add in manually, the network admin screens load as expected.

My .htaccess looks like this:

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

and the relevant parts of my wp-config.php look like this:

define( 'WP_ALLOW_MULTISITE', true );

define('MULTISITE', true);
define('SUBDOMAIN_INSTALL', false);
define('DOMAIN_CURRENT_SITE', 'local.dev');
define('PATH_CURRENT_SITE', '/');
define('SITE_ID_CURRENT_SITE', 1);
define('BLOG_ID_CURRENT_SITE', 1);

I already tried to change PATH_CURRENT_SITE from /to /wordpress/.
That fixes the url, but the network admin screen won't load because there are too many redirects, so it seems that the problem is in my .htaccess.

There I already tried this (as suggested here), but this does not solve the problem – the same error persists:

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

WordPress version is 4.0, the network was also started at this version.

Do you see whats wrong with this setup? How do I fix the 'too many redirects' error?

Edit: I investigated the issue a bit further. I tried to do the same with a single site installation and it worked without problems. My guess is that the warning message I quoted is there for a reason. Still, I would love to know if there is a fix or workaround for this. Also, I am now pretty sure that PATH_CURRENT_SITE must be /, which means it's clearly an .htaccess issue.

Share Improve this question edited Oct 11, 2014 at 21:10 Sven asked Oct 11, 2014 at 18:17 SvenSven 3711 gold badge6 silver badges18 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 2

network admin_url filter can rewrite network admin url.
But i don't know it is a best way or not.

// wp-config.php
/** Sets up WordPress vars and included files. */
require_once(ABSPATH . 'wp-settings.php');

// add code //
define('__WORDPRESS_CORE_DIR__', '/wordpress');

add_filter('network_admin_url', 'rewrite_my_network_admin_url', 10, 2);
function rewrite_my_network_admin_url($url, $path) {
  $networkPath = str_replace( '/wp-admin/', __WORDPRESS_CORE_DIR__ . '/wp-admin/', $url );
  return $networkPath;
}

http://chaika.hatenablog/entry/2018/02/03/090000 (japanese)

you must define path to current site like this :

define('PATH_CURRENT_SITE', '/wordpress/');

Articles related to this article

Post a comment

comment list (0)

  1. No comments so far