Wordpress multisite subdirectory infinite redirect loop for subsite admin pages

Any time I create a new site on my multisite install, I get an infinite loop redirect when navigating to that site's admin. I'm using the default htaccess supplied by WP for subdirectory. Here's what I have:

RewriteEngine On
RewriteBase /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]

FYI - My wp install is within a folder named 'site'. None of the solutions I've found on the web are working. Any help would be appreciated.

  • Vaughan

    Hi @everbaron,

    Can you also post your wp-config.php too. (remove the DB credentials).

    This might also help.

    http://codex.wordpress.org/Giving_WordPress_Its_Own_Directory#Using_a_pre-existing_subdirectory_install

    Also how long have you had this site? If you have had it since before wp 3.5 then your htaccess might be incorrect as pre 3.5 used a different method & rule.

    However if you installed it fresh, then something else might be wrong.

    It's much easier to install in the root of your server, rather than in a subfolder due to the way multisite works.

    Hope this helps

  • everbaron

    See attached for the config file. WP is in a subdirectory because we're building an app on top of it, and we're using composer to manage dependencies, including WP itself.

    It's a new install. We've only been working on it for about 2 months now, so we started with 3.8.

    FYI - APP_URL is defined in a separate local.php config file, along with the db credentials, so we can use the same code base on local/dev/production/etc.

  • everbaron
    <?php
    
    // App root
    define( 'APP_ROOT', dirname( __DIR__ ) );
    
    // Set APPLICATION_ENV on your server. Must match name of config file.
    define( 'APP_ENV', getenv( 'APPLICATION_ENV' ) );
    
    // ===================================================
    // Load database info and local development parameters
    // ===================================================
    
    if ( ( $cfg = '/config/env/local.php' ) && file_exists( APP_ROOT . $cfg ) ) {
    	require APP_ROOT . $cfg;
    } else if( ( $cfg = '/config/env/' . APP_ENV . '.php' ) && file_exists( APP_ROOT . $cfg ) ) {
    	require APP_ROOT . $cfg;
    } else {
      echo "<pre>";
      var_dump( getenv('APPLICATION_ENV') );
      echo "</pre>";
      die( "<pre>Error: configuration file '" . $cfg . "' not found. Unable to proceed.</pre>" );
    }
    
    // ========================
    // Custom Content Directory
    // ========================
    define( 'WP_CONTENT_DIR', APP_ROOT . '/content' );
    define( 'WP_CONTENT_URL', 'http://' . APP_URL . '/content' );
    
    // ================================================
    // You almost certainly do not want to change these
    // ================================================
    define( 'DB_CHARSET', 'utf8' );
    define( 'DB_COLLATE', '' );
    
    // Require Composer Autoload
    require_once APP_ROOT . '/vendor/autoload.php';
    
    /* Multisite */
    define( 'WP_ALLOW_MULTISITE', true );
    define('MULTISITE', true);
    define('SUBDOMAIN_INSTALL', false);
    define('DOMAIN_CURRENT_SITE', APP_URL);
    define('PATH_CURRENT_SITE', '/site/');
    define('SITE_ID_CURRENT_SITE', 1);
    define('BLOG_ID_CURRENT_SITE', 1);
    
    // domain mapping plugin
    // define('SUNRISE', 'on');
    
    // allow multi-domains per site
    // define( 'DOMAINMAPPING_ALLOWMULTI', 1 ); 
    
    // Help multisite admin redirect loop
    define('ADMIN_COOKIE_PATH', '/');
    define('COOKIE_DOMAIN', '');
    define('COOKIEPATH', '');
    define('SITECOOKIEPATH', '');
    
    // ==============================================================
    // Table prefix
    // Change this if you have multiple installs in the same database
    // ==============================================================
    $table_prefix  = 'wp_';
    
    // =============================
    // Update DB after domain change
    // =============================
    
    if ( defined( 'UPDATE_DB_DOMAIN' ) && UPDATE_DB_DOMAIN === true )
      require_once( APP_ROOT . '/config/update/updatedbdomain.php' );
    
    // ================================
    // Language
    // Leave blank for American English
    // ================================
    define( 'WPLANG', '' );
    
    // ======================================
    // Load a Memcached config if we have one
    // ======================================
    if ( file_exists( dirname( __FILE__ ) . '/memcached.php' ) )
    	$memcached_servers = include( dirname( __FILE__ ) . '/memcached.php' );
    
    // ===================
    // Bootstrap WordPress
    // ===================
    if ( !defined( 'ABSPATH' ) )
    	define( 'ABSPATH', APP_ROOT . '/site/' );
    require_once( ABSPATH . 'wp-settings.php' );

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.