WP Multisite – How to create a custom “router” for blog prefixes?

Maybe you are looking for a URL Rewrite (.htaccess) answer, but a simple solution is giving the site name its ID.

site name as id


Not related, but useful: add a column with the site ID in the Sites screen (/wp-admin/network/sites.php).

Drop the plugin in the mu-plugins folder.

<?php
/**
 * Plugin Name: Multisite - Add Site ID Column
 * Version: 0.1
 * Author: brasofilo 
 */

add_filter( 'wpmu_blogs_columns', 'brsfl_get_id' );
add_action( 'manage_sites_custom_column', 'brsfl_add_columns' , 10, 2 );
add_action( 'manage_blogs_custom_column', 'brsfl_add_columns' , 10, 2 );
add_action( 'admin_head-sites.php', 'brsfl_add_style' );

function brsfl_get_id( $columns ) 
{
    $columns['blog_id'] = __('ID');
    return $columns;
}

function brsfl_add_columns( $column_name, $blog_id ) 
{
    if ( 'blog_id' === $column_name )
    {
        echo $blog_id;
    }
    return $column_name;
}

function brsfl_add_style() 
{
    echo '<style>#blog_id { width:7%; }</style>';
}