WordPress development

Multisite or multi-site, create multiple websites with a single WordPress installation – Part 2

In this second part I am going to explain how you should build a multi-site setup with WordPress, codes, files that you have to edit, problems that you may encounter when implementing it, the new user super admin.

NOTE: This setup is advanced as you have to edit sensitive WordPress files, so if you have a production site, I advise you to try doing it on a local installation first.

How CBuild a multi-site setup with WordPres

  • The first thing you have to do is make a backup of your entire website, you can use a plugin or ask your hosting to do it and leave it somewhere on the hosting accessible to you, in case you have to go back.
  • Use Filezilla-like file sharing software to connect to your hosting
  • Next you must connect to your WordPress installation and look in the root directory of your WordPress for the file called wp-config.php and make a copy of this file on your computer, as it is at that moment, before editing it.
  • Open the file with a code editor or with the notepad.
  • Look for the line where it says: /* That's it, stop editing! Happy blogging */ Add the following line of code just above it:
define( 'WP_ALLOW_MULTISITE', true );
  • We save the file 
  • Enter your WordPress administrator by logging in with your administrator user. 
  • We look for, in our menu on the left sidebar of the WordPress admin, the option “Tools”
  • There we will see that a new option has been created called "Network Configuration"
  • We enter this option and see the different sections
  • On the one hand, it tells us that the file that we have previously edited, in the wp-config.php file, we must add these lines just below the one we have just written:
define('SUBDOMAIN_INSTALL', false); // true o false = subdomino o directorios
define('DOMAIN_CURRENT_SITE', 'misitio.com');
define('PATH_CURRENT_SITE', '/');
define('SITE_ID_CURRENT_SITE', 1);
define('BLOG_ID_CURRENT_SITE', 1);
  • If we want to implement the sites in directories like myweb.com/site1, we will leave the first line as is, but if we want to implement the sites with subdomains like site1.mysite.com we will change "false" to "true" in the first line.
  • On the other hand, it tells us that you must modify the .htaccess file
  • We look for the .htaccess file, also in the root directory where we have the WordPress installation, and we make a copy as it is at this moment on our computer.
  • We now edit this file.
  • We are going to delete all the files previously created with the installation of WordPress :
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
  • We replace it with this other one:
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [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).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]

IMPORTANT: This change from here above is usually the one that sends the most errors, we forgot to remove the .htaccess code and when saving the browser tells us that there are too many redirects. This is fixed by removing the old code and replacing it with the latter.

  • We save the files, when loading the browser it will disconnect us from the WordPress administrator to send us to the login.
    once connected We are already "Super Administrators"
  • We already have the multi-site configuration with WordPress

If you need to implement a multi-site on your website or a WordPress development from scratch exclusively for you or for your client, do not hesitate to contact us, and we will give you the best solution or if you need other developments ask us for a quoteYou will be pleasantly surprised at our prices. I also recommend reading the entry How much does a website made with WordPress cost?

¡Subscribe to our newsletter and receive our offers, news and discounts directly to your email!