A WordPress Multisite is an installation that shares the same files, and generates different tables according to the different installations and therefore shares functionalities between them.
It is a very smart solution for certain needs such as multi-language sites (like this one), multi-country, division of functionalities to make the main site less cumbersome.
This is because we can create/install plugins for our different installations. It may happen that we activate an entire online store on a subsite in order to maintain maximum performance on the main portal. This type of installation usually occurs in very large sites.
This guide is a compilation of different sites to be able to install the multisite with the two configurations: subdomains and subfolders. The subdomains option can also be used in the multidomain configuration. It will only be necessary once a subdomain has been created, to change its address to the final one.
At Closemarketing we have this Multisite WordPress Development service.
The main site is the Official WordPress HandBook, which the first thing it tells us to do is paste this line into the wp-config.php file:
.define( 'WP_ALLOW_MULTISITE', true );
This will enable a new menu under Tools > Network Administration.
Subfolder configuration
.Configuration in wp-config
define('MULTISITE', true);
define('SUBDOMAIN_INSTALL', false);
define('DOMAIN_CURRENT_SITE', 'domain.com');
define('PATH_CURRENT_SITE', '/');
define('SITE_ID_CURRENT_SITE', 1);
define('BLOG_ID_CURRENT_SITE', 1);
.
Configuration in htaccess
# BEGIN WordPress Multisite SUBFOLDER.
<IfModule mod_rewrite.c>
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]
</IfModule>
Configuration-with-subdomains
.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);
.
Htaccess if it is a subdomain
# BEGIN WordPress Multisite SUBDOMAIN.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteRule ^wp-admin$ wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(wp-(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^(.*.php)$ $1 [L]
RewriteRule . index.php [L]
</IfModule>
And another important thing for multisite, is that if we make a mistake with the address and put www or without www, it will redirect to a registration page of the new site. This is rarely used, so we want to disable it, by adding this code in wp-config:
define( 'NOBLOGREDIRECT', 'https://dominio.com' );
Configuration cookies for multidomain
.If you want the multidomain option, that is domain.com, domain.es, etc. so that there are no problems with cookies, you will have to add these lines in wp-config:
define('COOKIE_DOMAIN', $_SERVER['HTTP_HOST'] );
Leave a Reply