I will try to put step by step here everything you need to do to enable the Wordpress multisite. Come on.
Requirements
- Wordpress 3.0 or higher. (recommend the latest version).
- Support wildcards in host subdomain creation.
If you need to use WP MS with subdomains, that is, access your websites created in the WP instance using: http://site1.example.com
, http:///site2.example.com
and so on, your host will need have wildcard support in creating subdomains. Your main website would be on http://example.com
and the other sites under that domain.
What are the wildcards?
When you create a host subdomain, 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 of responding to domain calls (requests) to WP. Therefore, you have to create a wildcard domain that answers to any name. This can be done when you create the domain using:
*.example.com
-> /home/seuusuario/example.com/public_html
This way, any request made before example.com will be forwarded to the WP installed in the folder /home/seuusuario/example.com/public_html
. If WP is configured as MS it will respond with due site created within MS.
Create wildcards for subdomains (skip if not using subdomains)
As explained above, you will need to access your host’s control panel and create a subdomain with the name of *.example.com
or, depending on the host, %.example.com
. Point Documentroot to the folder where your WP installation is or where you will install WP.
If you don’t find this option or the host won’t allow it, open a call asking if you can create a subdomain using wildcards and if so, how you do it. If the host respond negatively, then you will only have the option to create more websites within WP using the sub-directory option, unfortunately.
If you have already created domains from the dashboard and want to use in WP MS, remove these subdomains.
Enabling the WP MS
Created the subdomain settings, we will now enable Multisite in Wordpress. For 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 by browser. Log in to the WP administration and go to Tools > Network Setup
.
Choose how to install from sub-domains or sub-folders. Remember the above settings if using subdomains.
Complete the installation by adjusting the wp-config.php
and the .htaccess
according to the instructions of this temporary page in Tools.
Altering the wp-config.php
Add these lines after the first one before:
/* Multisite */
define( 'WP_ALLOW_MULTISITE', true ); // <-- depois desta
define('SUBDOMAIN_INSTALL', true);
define('DOMAIN_CURRENT_SITE', 'seudominio.com.br');
define('PATH_CURRENT_SITE', '/');
define('SITE_ID_CURRENT_SITE', 1);
define('BLOG_ID_CURRENT_SITE', 1);
Altering the .htaccess
Now all that remains is to change the .htaccess
because it is a little 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]
After that change the files wp-config.php
and .htaccess
, will have to login again and will appear the full Network environment.
Changing the type of sub-domain installation to sub-folders or vice versa
If you want to change the type of installation from one type to the other after you have done a previous installation, do the following. Open the file wp-config.php
and modify the following line:
define( 'SUBDOMAIN_INSTALL', true );
Use the flag true
to use the installation by sub-domains and false
to use installation by sub-folders.
Domain mapping
Mapping is to make a Multisite site site work with its own domain, that is, map site.example.com
to run as site.com
.
Previously it was necessary the plugin Wordpress MU Domain Mapping but nowadays this is native in Wordpress. Just set the site URL with the mapped domain site.com
and mapping is done automatically, noting that DNS and SSL should already be working before mapping the domain.
Sources:
this . htaccess that you put to the question is your domain or Wordpres Codex?
– Ricardo BRGWeb