Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Spencer Bryant

    (@szb0018)

    Sorry about not elaborating on the $base variable. You are correct in that the plugin does not reference it; however, that is the problem. WordPress uses the variable when creating new blogs for a site. $base is defined in wp-config by default when you enable multisites. But since your plugin allows multiple sites, it needs to update that variable for each site. I noticed the issue when creating sites whose domain/path were a child of another site’s domain/path. The fix is really simple:

    function set_base_var() {
    global $base;

    if ( !is_multisite() )
    return;

    $base = get_current_site()->path;
    }

    add_action( 'muplugins_loaded', 'set_base_var');

    It may be better to use a different action hook, but this one seems to work just fine.

    As for the .htaccess file, it is a pretty simple adjustment as well. All it does is allow the rewrite rules to handle urls to nested sites.

    RewriteEngine On
    RewriteBase /

    # Rule 1
    RewriteRule ^index\.php$ - [L]

    # Rule 2: uploaded files
    RewriteRule ^([_0-9a-zA-Z-]+/)*files/(.+) wp-includes/ms-files.php?file=$2 [L]

    # Rule 3: add a trailing slash to "/wp-admin"
    # Note: This rule issues and redirect that will subsequently match Rule 5
    RewriteRule ^(([_0-9a-zA-Z-]+/)*)wp-admin$ $1wp-admin/ [R=301,L]

    # Rule 4: do nothing if URL is a file or directory
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^ - [L]

    # Rule 5: strip preceeding path from wp-(content|admin|includes) paths
    # Example: {RewriteBase}sub-site/sub-folder/wp-admin/sites.php --> {RewriteBase}wp-admin/sites.php
    RewriteRule ^([_0-9a-zA-Z-]+/)*(wp-(content|admin|includes).*) $2 [L]

    # Rule 6
    RewriteRule ^([_0-9a-zA-Z-]+/)*(.*\.php)$ $2 [L]

    # Rule 7
    RewriteRule . index.php [L]

    My email is (hopefully): s z b 0 0 1 8 @ a u b u r n . e d u

    Thread Starter Spencer Bryant

    (@szb0018)

    I did a fresh install of WordPress, and everything started working just fine. So it was probably a problem with theme or another plugin.

Viewing 2 replies - 1 through 2 (of 2 total)