The MU forums have moved to WordPress.org

Migrating WP to WPMU -- retaining old permalinks (6 posts)

  1. elvix
    Member
    Posted 16 years ago #

    Hi all,

    I've got a WPMU install using subdirectories that's managing several former WP blogs. New registrations are off.

    I need route the old main blog's (domain root) permalinks to the new root blog.

    All I need to do is either remove the /blog/ from the root blog's permalinks, or create an htaccess rule that would route old post permalinks to new.

    OLD: DOMAIN/%year%/%monthnum%/%day%/%postname%/
    NEW: DOMAIN/blog/%year%/%monthnum%/%day%/%postname%/

    It seems like an htaccess rule would be easiest. Since I control creation of new blogs, I'm assuming name collisions won't be an issue (I could easily be wrong on this).

    I was thinking I could test for a year at the beginning of the path, and then insert "/blog/" at the beginning the path.

    Anyone know how to create this kind of rule? Nothing I've tried has worked.

    Am I barking up the wrong tree? Is there a different solution? (I've searched and searched the forums, to no avail.)

  2. theapparatus
    Member
    Posted 16 years ago #

    Thank you for searching first. Please see if this post will help you as a plugin or the other thread linked in there to actually remove it from the code.

  3. elvix
    Member
    Posted 16 years ago #

    Thanks, i hadn't found this plugin post. It doesn't seem to be working (permalinks w/o blog don't work and permalinks w/ blog give 404), but I'll keep digging around.

  4. elvix
    Member
    Posted 16 years ago #

    I think I resolved my problem.

    (NOTE: I am using subdirectories, so most of the other solutions I'd read about in the forums didn't apply -- most times people recommended using subdomains, which I didn't want to do. )

    First, I removed all references to "blog/" in wp-admin/options-permalinks.php and regenerated the root blog's permalinks, as stated here:

    http://mu.wordpress.org/forums/topic.php?id=3672&page&replies=16#post-23473

    Then I modified wpmu-settings.php (around line 100 in my version), adding one final if statement.

    } else {
    $current_blog = $wpdb->get_row("SELECT * FROM $wpdb->blogs WHERE domain = '$domain' AND path = '{$path}{$blogname}/'");
    
    /*ADD*/
    
    if($current_blog == null )
    $current_blog = $wpdb->get_row("SELECT * FROM $wpdb->blogs WHERE blog_id = '1' "); // the root blog
    
    /*END ADD*/
    
    }

    Since WPMU seems to need to set the $current_blog from the permalink, and I'd removed this critical information, this final statement makes sure that $current_blog gets set with something.

    I've got my fingers crossed, in any case. :)

  5. theapparatus
    Member
    Posted 16 years ago #

    That should be right. A link was included within that thread I pointed you to that covered doing a manual edit if you want to double check your work.

    Glad you got it working though.

  6. honewatson
    Member
    Posted 16 years ago #

    Awesome that worked well for a subdirectory install of mine.

About this Topic

  • Started 16 years ago by elvix
  • Latest reply from honewatson