Prosites deploying site to a different url


I would like to use Prosites to deploy customer sites on my multisite network. However I would like the site to be deployed to a different url. I have looked at Domain mapping and it doesnt quite do what I want.

Basically my site url is but I want the customers sites to be deployed to

Is this possible with Prosites and wordpress?

Many thanks.

  • Adam Czajczyk

    Hi itsnotrocketsurgery

    The Pro Sites plugin can only work with the same multisite it's installed in. With Domain Mapping it's possible to allow sub-site admins to map their own domains to their sites but still - that doesn't let you "automatically deploy" to these domains. The "flow" would be: user registers for site, site is created under the main domain (sub-domain or sub-folder, depending on site's setup), then user is able to add other domain(s).

    However, what you described is yet another scenario. It wouldn't be possible "out of the box", I'm afraid. But I'm not sure if there might be a workaround or not as I don't quite understand the setup.

    I understand that the multisite is installed under a "" and that's the main site of it as well, right?

    It's also a sub-folder based install, correct? A "sub-folder" install means that by default new sites would be created like:

    and so on.

    Now, how does that related to the ""? I mean, is this some sub-site of the "" multisite install or is it a separate multisite install? Or it's just an URL you would want to use for the sub-sites of "" site?

    Please elaborate on this a bit and I'll see if there might be some relatively easy patch/workaround.

    Best regards,

  • itsnotrocketsurgery

    Hi Adam

    You are correct with how the site is set up.

    I would like /s/ added to the url so I can determine which sites are customer sites as I have a few other sub sites that are mine, such as a blog.

    It wouldn't be a separate multisite or sub-site. I just want the capability to add the /s/ to the url when a site is deployed.

    I currently have a work around on there with a plugin I had developed but would really like to use Prosites and wondered if I could do the same.

    Hope this makes sense.


  • Adam Czajczyk

    Hi itsnotrocketsurgery

    Thanks for explanation!

    I think it might be doable, though I'd rather not make any promises yet. It will require some custom code for sure and the question is whether we will be able to somehow "hook" some simple snippet to the Pro Sites and/or WP or if it would require some "deep changes" in plugin's core.

    I'll be happy to give it a try to see if we can achieve that. Would you mind me moving this thread to our support forum as it's related to our plugin features? This way I could also include our 2nd-line support/developers for consultation.

    It would be also great if you could share your current solution with me (you can either post it on pastebin or upload to some file storage like your Dropbox or Google drive and just share a download link here with me). I'd like to take a look at how are you doing that now to see if perhaps that could be 'hooked to Pro Sites" or partially re-used.

    Looking forward to your reply,

  • Adam Czajczyk

    Hi itsnotrocketsurgery,

    I hope you're well today and I apologize for keeping you waiting!

    I played a bit with Pro Sites code but it seems there's no suitable filters/actions available at the moment so we'd need to go a bit different way but it seems that it would be possible. I came up with a small code that just takes an ID of the newly created blog and updates its settings after that. It does that "fast enough" to present a user with an updated blog URL so that should be fine. It will, however, work for all newly created sites, regardless whether they are created via Pro Sites (and which level) or via back-end.

    You would probably also need some sort of .htaccess rewrite but since you already are using that sort of URL structure, I recon you already got that part sorted out.

    The code to use as MU plugin would be like that:

    function wpmu_ps_blog_details_changer($blog_id) {
    	$blog_details = get_blog_details( $blog_id ); // get blog details
    	// extract path
    	$current_path = $blog_details->path;
    	// modify path
    	$new_path = '/s' . $current_path;
    	// modify site URL
    	$new_siteurl = str_ireplace( rtrim ( $current_path, "/"), rtrim( $new_path, "/"), $blog_details->siteurl );
    	// update blog details
    		$result = update_blog_details( $blog_id, array( 'path' => $new_path ) );
    	switch_to_blog( $blog_id );
    	update_option( 'siteurl', $new_siteurl );
    	update_option( 'home', $new_siteurl );
    add_action( 'wpmu_new_blog', 'wpmu_ps_blog_details_changer', 99, 2 );

    You could probably modify it a bit more if you need but I'm leaving that up to you. The path modification is this line:

    $new_path = '/s' . $current_path;

    so here you're adding your "/s" or anything else you want to use in that modified URL.

    Best regards,

  • Adam Czajczyk

    HI itsnotrocketsurgery

    Thanks for your response.

    If it does change URLs but you can't access the site that means that some additional code would be required. I've seen your code but I assume that you got some sort of .htaccess (or other kind) of URL rewrites that's taking care of these changed URLs.

    I understand that you had that working - just not with Pro Sites - right? I might have missed something when checking your code but if your code was/is changing the URL and these sites are still accessible - how did you solve that there? Maybe we could actually "re-factor" that solution to be used with my code? Just thinking...

    If not, let me know and I'll do a bit more research as previously I assumed that there'll be no need to take care of that part - that you just need these sites to be created that way :slight_smile:

    Best regards,

  • itsnotrocketsurgery

    Hi Adam

    I assume that you got some sort of .htaccess (or other kind) of URL rewrites that's taking care of these changed URLs.

    I a not sure what you mean here, I dont have anything in the .htaccess

    I understand that you had that working - just not with Pro Sites - right?

    Pro sites deployed sites and you could access them, but once I use your code to change the URL I can no longer access the sites deployed. If I change the url back without the /s/ then the site works fine again.

    Many thanks.

  • Adam Czajczyk

    Hello @itsnotrocketsurgery!

    I realize that the sites deployed by Pro Sites with my code cannot be access with a regular Multisite configuration. I only focused on creating code that would alter the URL and path upon site creation because I assumed your site is already set to be able to handle such sort of url (with additional /s/ in "slug").

    Earlier in this thread you mentioned that you are using a solution in a form of your own plugin, which you shared here:

    This plugin also deploys sites with that "/s/", right? So, my question in my last post was: assuming that the main site is at "", your plugin would create sub-site at "", correct?

    Now, does such sub-site created with your plugin (not my code) work? Is it available/accessible - both front end and back-end?

    I'm asking because forcing Pro Sites to create such url is one thing (and that's what my code does) but making WordPress to handle such URL is another thing and I admit I'm not sure about it. So, if your code works without any additional "special" changes in WP configuration - like additional rules in .htaccess or changes in wp-config.php or anything else - then I'm clearly missing something. If there are any "special changes" instead, would you tell me what they are? Or the sites created with your code with that /s didn't work either?

    I actually noticed that there's some error log in the code that you shared and it suggests that sites with /s in URLs didn't work... but these are over a year old errors there.

    The reason for me asking about that all is this: I never created a setup like this and I actually am not even sure if that would be possible without "hacking" WP core. I provided the code to make Pro Sites deployed sites have altered URL, as requested, but if the question is how to actually make such URL work, then I'll need to do more research to find out if that's even possible and if so, how. I hope that makes a bit more sense now :wink:

    Kind regards,

  • Adam Czajczyk

    Hello itsnotrocketsurgery,

    Thanks for response and I'm sorry for the delay. I've been looking for possible solutions to this and that took a while.

    In fact, it turns out that there should be a way to make it work - to get those sites "recognized". While my scrip creates "altered" site configuration, the point is to make WordPress grab and handle such sites. A special file called "sunrise.php" (similar to what's used in Domain Mapping plugin) comes in handy here.

    I was able to get "some success" with a slightly modified sunrise.php of the Domain Mapping plugin. This is the code that I used:

    # SUNRISE file for custom pro sites subsite URL
    global $wpdb;
    // get requested site path
    $request_path = strtolower( parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH) );
    error_log( "REQUESTED SITE PATH:" . $request_path );
    $s_e = $wpdb->suppress_errors();
    // find site by path
    $altered_path = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->blogs} WHERE  path = %s LIMIT 1", $request_path), OBJECT );
    if ( $altered_path ) {
    	error_log( "REQUESTED SITE ID:" . $altered_path->blog_id );
        $current_blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->blogs} WHERE blog_id = %d LIMIT 1", $altered_path->blog_id ) );
        $current_blog->domain = $_SERVER['HTTP_HOST'];
        $blog_id = $altered_path->blog_id;
        $site_id = $current_blog->site_id;
        $current_site = $wpdb->get_row( $wpdb->prepare( "SELECT * from {$wpdb->site} WHERE id = %d LIMIT 1", $current_blog->site_id ) );
        $current_site->blog_id = $wpdb->get_var( $wpdb->prepare( "SELECT blog_id FROM {$wpdb->blogs} WHERE domain = %s AND path = %s", $current_site->domain, $current_site->path ) );
    	// The function get_current_site_name is deprecated as of 3.9
        global $wp_version;
        if ( version_compare($wp_version, "3.9", "<") && function_exists( "get_current_site_name" ) ) {
            $current_site = get_current_site_name( $current_site );
        //set site_name
        if( !isset( $current_site->site_name ) || empty($current_site->site_name) ){
            $current_site->site_name = wp_cache_get( $current_site->id . ':site_name', 'site-options' );
            if ( ! $current_site->site_name ) {
                $current_site->site_name = $wpdb->get_var( $wpdb->prepare( "SELECT meta_value FROM $wpdb->sitemeta WHERE site_id = %d AND meta_key = 'site_name'", $current_site->id ) );
                if ( ! $current_site->site_name )
                    $current_site->site_name = ucfirst( $current_site->domain );
                wp_cache_set( $current_site->id . ':site_name', $current_site->site_name, 'site-options' );
        $current_blog->path = $current_site->path;
    	// Added for belt and braces
        if ( !defined( 'WP_CONTENT_URL' ) ) {
            // full url - WP_CONTENT_DIR is defined further up
            define( 'WP_CONTENT_URL', ( is_ssl() ? 'https://' : 'http://' ) . $current_blog->domain . $current_blog->path . 'wp-content' );
    // clean up temporary variables
    unset( $s_e, $request_path );

    This code should be put into the file named "sunrise.php" and the file should be put into the "/wp-content/" folder of your multisite. Additionally, you would need to add following line to the "wp-config.php" file of the site (above "/* That's all, stop editing */"):


    Now, the problem is that only works partially: the homepage of a new site loads fine. Still, the sub-pages (pages/posts) are returning "Not found" and the wp-admin is also returning that. The good "sign", though, is that unlike before it is now giving "Not Found" while keeping a proper URL.

    That confirms that it's a correct path to follow but I admin I'm not sure what more should be handled in a sunrise.php file and how. I think that there should be some additional code to handle back-end (wp-admin) and I also suppose there might have to be added some sort of rewrite rules (permalinks) configuration upon site creation.

    I'm afraid though that this is as far as I can get as it already goes way too far into custom coding. I'm sure that the sunrise.php is the way to go here and I think that the code posted above would give a foundation but that would need more research and custom development, which I won't be able to provide. I hope that makes sense to you.

    Kind regards,

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.