Is there a way to change things from sub-folder to sub-domain?

I've found that I'm going to have to use sub-domains rather than sub-folders in my Multisite.

Is there a way to do this without messing everything up?

  • Vaughan

    Hi Dark Scream,

    It's possible, but not easy, especially if you alredy have lots of blogs created already.

    First you need to edit your wp-config.php & set the subdomain define to true in the multisite section.

    /* Multisite */
    define('WP_ALLOW_MULTISITE', true);
    define('MULTISITE', true);
    define('SUBDOMAIN_INSTALL', true);
    define('DOMAIN_CURRENT_SITE', 'domain.com');
    define('PATH_CURRENT_SITE', '/');
    define('SITE_ID_CURRENT_SITE', 1);
    define('BLOG_ID_CURRENT_SITE', 1);

    Next you need to edit the htaccess and change it to the subdomain version. which as default looks like;

    # BEGIN WordPress
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    
    # add a trailing slash to /wp-admin
    RewriteRule ^wp-admin$ wp-admin/ [R=301,L]
    
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^ - [L]
    RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
    RewriteRule ^(.*\.php)$ $1 [L]
    RewriteRule . index.php [L]
    # END WordPress

    Once done, you then need to create a wildcard subdomain for your multisite domain.

    This is done by creating a subdomain in your CPanel

    *.domain.com & point it at your multisite documentRoot (the folder where your wp-config.php resides)

    Now the fun begins, because now you need to change all the URL references for all your subsites.

    You can use a plugin for this, but in my experience, it is only successful 99% of the time. so sometimes you will still need to make manual changes.

    https://wordpress.org/plugins/search-and-replace/

    you can then enter the URLS in the search & replace

    for example.

    Search for domain.com/subsite

    replace with subsite.domain.com

    You will need to do this for every subsite you have.

    Once done, regenerate the permalinks on every subsite.

    If all is well, you should be good to go. don't threat if it doesn't work first time, you would need to do this manually for each subsite in that case, not difficult, but very time consuming either way if you have a lot of blogs.

    Hope this helps

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.