Steps to change WordPress Multisite from Subdomain to Subdirectory

I decided to change the multisite’s URL structure from to because of the reason I explained in why prefer multisite with subdirectory url structure over subdomains post for WordPress Multisite.

I searched over internet and what I found on internet was very close to what I was trying. So I am writing this post to list out step by step what precisely worked for my site while changing the multisite WordPress from subdomain to subdirectory structure.

Steps: WordPress Multisite from Subdomain to Subdirectory

  1. Before doing any changes, do take a backup described on the official WordPress site: Backup WordPress Database
  2. Now, take backup of the files you are going to modify e.g. .htaccess
  3. Now, open your .htaccess file from the root directory of your WordPress install and replace the code between “# BEGIN WordPress” & “# END WordPress”. There are instructions for updating code based on your WordPress version but it was really very confusing for me. So I tried different options and the code below worked for me.

    # BEGIN WordPress
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]

    # uploaded files
    RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]

    # add a trailing slash to /wp-admin
    RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]

    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^ - [L]
    RewriteRule ^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*) $1 [L]
    RewriteRule ^[_0-9a-zA-Z-]+/(.*\.php)$ $1 [L]
    RewriteRule . index.php [L]
    # END WordPress

  4. Ensure that you set redirects at subdomains level to not lose on any traffic. Use the following code to setup the redirects just above “# BEGIN WordPress” that you updated in the previous step. I have copied the exact code from my wp-config for your understanding. Note that is the main domain and subdomains are tv, fashion, storage, mobile, mechanical & travelogue. Use the exact code below and only change your domain and subdomain names. The back slashes and quotes are important and that what made it work.

    # Subdomains
    RewriteCond %{HTTP_HOST} ^$
    RewriteRule ^(.*)$ "http\:\/\/tipscow\.com\/tv\/$1" [R=301,L]

    RewriteCond %{HTTP_HOST} ^$
    RewriteRule ^(.*)$ “http\:\/\/tipscow\.com\/fashion\/$1” [R=301,L]

    RewriteCond %{HTTP_HOST} ^$
    RewriteRule ^(.*)$ “http\:\/\/tipscow\.com\/storage\/$1” [R=301,L]

    RewriteCond %{HTTP_HOST} ^$
    RewriteRule ^(.*)$ “http\:\/\/tipscow\.com\/mobile\/$1” [R=301,L]

    RewriteCond %{HTTP_HOST} ^$
    RewriteRule ^(.*)$ “http\:\/\/tipscow\.com\/mechanical\/$1” [R=301,L]

    RewriteCond %{HTTP_HOST} ^$
    RewriteRule ^(.*)$ "http\:\/\/tipscow\.com\/travelogue\/$1" [R=301,L]

  5. If there are not many subsites, you can simply goto and edit the paths from “/” to particular “subdomains”.
    change subsites structure from subdomain to subdirectory
  6. If you have many subsites, you can update them using phpMyAdmin from your cPanel.

If you run into any issues, restore the backup and try again. If there are still any problems, discuss them here and I would be glad to help you.

2 Comments on "Steps to change WordPress Multisite from Subdomain to Subdirectory"

  1. you say to edit wp-config.php but the instructions you give are for .htaccess.

    And, then, you forget to explain the changes that must be done in wp-config.php

Leave a comment

Your email address will not be published.