I'll try to put step by step here everything you need to do to enable WordPress Multisite . Come on.
Requirements
- WordPress 3.0 or higher. (I recommend the latest version).
- Wildcard support for subdomain creation by the host.
If you need to use WP MS with subdomains, that is, access your sites created in the WP instance using: http://site1.example.com
, http:///site2.example.com
and so on, your host will need wildcards support in creating subdomains . Your primary site would stay in http://example.com
and the other subdomain sites in that domain.
What are wildcards?
When you create a subdomain under host, you usually specify the name of the subdomain and the root folder it should read. For example:
-
http://site1.example.com
- /home/seuusuario/site1/public_html
-
http://site2.example.com
- /home/seuusuario/site2/public_html
However, you will need to transfer this responsibility from responding to domain requests to WP. So you have to create a wildcarded domain, which responds to any name. This can be done when you create the domain using:
-
*.example.com
- > /home/seuusuario/example.com/public_html
In this way, any request made before example.com will be forwarded to the WP installed in the /home/seuusuario/example.com/public_html
folder. If WP is configured as MS it will respond with the due site created within MS.
Create wildcards for subdomains (skip if not using subdomains)
As explained above, you will have to access the control panel of your host and create a subdomain with the name of *.example.com
or, depending on the host, %.example.com
. Point the DocumentRoot to the folder where your WP installation is located or where you will install WP.
If you do not find this option or the host does not allow it, open a call asking if it is possible to create a subdomain using wildcards and if it is, just like you do. If the host responds negatively, then you will only have the option to create more sites within WP using the sub-directories option , unfortunately.
If you have already created domains through the dashboard and want to use them in WP MS, remove those subdomains.
Enabling WP MS
Created subdomain settings, let's now enable Multisite in WordPress. To do this, open the file wp-config.php
and add the following line:
/* Multisite */
define( 'WP_ALLOW_MULTISITE', true );
Save the file, and access your WordPress through the browser. Log in to WP admin and go to Tools > Network Setup
.
Choose how to install between sub-domains or sub-folders . Remember the above settings if you use subdomains.
Finish the installation.
Changing the .htaccess
Now we only need to change the .htaccess
because it is a bit different when used with WP MS. Open your .htaccess
and replace it all with the following content according to the type of your installation:
Sub-domains
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)$ wp/$1 [L]
RewriteRule . index.php [L]
Sub-folders
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]
Made the changes, clear the caches and test.
Changing the subdomain installation type to subfolders or vice versa
If you want to change the installation type from one type to another after you have done an installation, do the following. Open the file wp-config.php
and modify the following line:
define( 'SUBDOMAIN_INSTALL', true );
Use the true
flag to use sub-domain installation and false
to use sub-directory installation.
Domain mapping
To make a Multisite site work with a domain of its own, that is, to map site.example.com
to run as site.com
, you need the following plugin:
WordPress MU Domain Mapping
Map any blog / site on a WordPressMU or WordPress 3.X network to an external domain.
Sources: