Switch a Single Site from WordPress Multi-site to a Standalone Installation

Like Comment
Switch multi-site wordpress to standalone

Moving a site out of a WordPress Multi-site network is a high-stakes task for any System Administrator. Unlike a standard migration, you must isolate specific database tables, remap file paths, and reconfigure user permissions.

If you are managing an AdSense-approved domain, following a precise “Clean Extraction” method is critical to maintaining SEO and revenue. Here is the step-by-step technical blueprint.

Phase 1: Database Extraction (The “Isolate” Phase)

In a Multi-site environment, each site is assigned a unique ID (e.g., Site 7). Its tables are prefixed accordingly (e.g., wp_7_posts).

  1. Isolate Site Tables: Use mysqldump or a database manager to export only the tables associated with your Site ID.
  2. Include Global User Tables: Don’t forget to export wp_users and wp_usermeta. These are shared across the network, and you’ll need them to log in to your new standalone site.
  3. Table Renaming: In your new standalone database, rename your specific tables to the standard prefix. For example, rename wp_7_posts to wp_posts.
#!/bin/bash
# Configuration
DB_NAME="your_multisite_db"
USER="your_db_user"
PASS="your_db_password"
SITE_ID=7
PREFIX="wp_" # Change this if your prefix is different

# 1. Export site-specific tables
# 2. Export shared user tables (Essential for login)
mysqldump -u$USER -p$PASS $DB_NAME \
$(mysql -u$USER -p$PASS $DB_NAME -e "SHOW TABLES LIKE '${PREFIX}${SITE_ID}_%'" | grep -v Tables_in) \
${PREFIX}users ${PREFIX}usermeta > mysite_standalone_backup.sql

echo "Backup complete: mysite_standalone_backup.sql"

After importing the .sql file into your new standalone database, run these SQL queries to rename the tables from the Multi-site format (wp_7_) to the standard standalone format

The Renaming Script: Convert to Standalone
-- Rename core site tables
RENAME TABLE wp_7_posts TO wp_posts;
RENAME TABLE wp_7_postmeta TO wp_postmeta;
RENAME TABLE wp_7_options TO wp_options;
RENAME TABLE wp_7_terms TO wp_terms;
RENAME TABLE wp_7_term_taxonomy TO wp_term_taxonomy;
RENAME TABLE wp_7_term_relationships TO wp_term_relationships;
RENAME TABLE wp_7_commentmeta TO wp_commentmeta;
RENAME TABLE wp_7_comments TO wp_comments;
RENAME TABLE wp_7_links TO wp_links;

-- Note: Repeat for any custom tables created by plugins (e.g., wp_7_icl_translations)
The Permission Fix (Crucial)
-- Align user capabilities with the new standalone prefix
UPDATE wp_options SET option_name = 'wp_user_roles' WHERE option_name = 'wp_7_user_roles';
UPDATE wp_usermeta SET meta_key = 'wp_capabilities' WHERE meta_key = 'wp_7_capabilities';
UPDATE wp_usermeta SET meta_key = 'wp_user_level' WHERE meta_key = 'wp_7_user_level';

Phase 2: File Migration & Path Correction

Multi-site handles media differently than standalone WordPress, storing files in a deep directory structure.

Path Remapping: You must update the database to reflect this change. Using WP-CLI is the safest way to handle serialized data:

The Uploads Move: Move your media from wp-content/uploads/sites/X/ (where X is your Site ID) to the standard standalone directory: wp-content/uploads/.

Once your wp-config.php is connected to the new database, run this command in your terminal to fix the image paths and prevent broken links on your AdSense-approved site:

# Correcting the internal media paths
wp search-replace 'wp-content/uploads/sites/7/' 'wp-content/uploads/' --all-tables

Phase 3: wp-config.php and .htaccess Cleanup

Your new site needs to “forget” it was ever part of a network.

  1. Strip Multi-site Constants: Remove lines like MULTISITE, SUBDOMAIN_INSTALL, and DOMAIN_CURRENT_SITE from your wp-config.php.
  2. Reset Permalinks: Replace the complex Multi-site .htaccess rules with the standard WordPress block.
  3. Hardcode URLs for Staging: If testing on a local environment like XAMPP, use overrides to prevent the site from redirecting to the live production URL:
define( 'WP_HOME', 'http://localhost/sitename' );
define( 'WP_SITEURL', 'http://localhost/sitename' );

To ensure zero downtime for revenue:

  • SSL & VHosts: Re-issue Let’s Encrypt certificates for the new standalone virtual host.
  • ads.txt: Move your ads.txt file to the new standalone root directory immediately to keep AdSense active.
  • 301 Redirects: If your Multi-site used a /blog/ prefix or specific directory paths, set up 301 redirects at the Nginx/Apache level to preserve SEO.

You might like

Avatar

About the Author: webmaster

Leave a Reply

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