WordPress MU Domain Mapping

This plugin allows users of a WordPress MU site or WordPress 3.0 network to map their blog/site to another domain.

It requires manual installation as one file must be copied to wp-content/ and another file to wp-content/mu-plugins/. When upgrading the plugin, remember to update domain_mapping.php and sunrise.php. Full instructions are on the Installation page and are quite easy to follow. You should also read this page too.

Super administrators must configure the plugin in Super Admin->Domain Mapping. You must enter the IP or IP addresses (comma deliminated) of your server on this page. The addresses are purely for documentation purposes so the user knows what they are (so users can set up their DNS correctly). They do nothing special in the plugin, they’re only printed for the user to see.

You may also define a CNAME on this page. It will most likely be the domain name of your network. See below for some restrictions and warnings.

Your users should go to Tools->Domain Mapping where they can add or delete domains. One domain must be set as the primary domain for the blog. When mapping a domain, (like ‘example.com’) your users must create an A record in their DNS pointing at that IP address. They should use multiple A records if your server uses more than one IP address. If your user is mapping a hostname of a domain (sometimes called a “subdomain”) like http://www.example.com or blog.example.com it’s sufficient to create a CNAME record pointing at their blog url (NOT IP address).

The login page will almost always redirect back to the blog’s original domain for login to ensure the user is logged in on the original network as well as the domain mapped one. For security reasons remote login is disabled if you allow users to use their Dashboard on the mapped domain.

Super admins can now choose to either allow users to setup DNS ANAME records by supplying an IP (or list of IP addresses) or set a CNAME but not both (entering a CNAME for the end user voids the use of IP’s)

There is a lot of debate on the handling of DNS using CNAME and ANAME so both methods are available depending on your preference and setup.

Things to remember:

  • CNAME records that point to other CNAME records should be avoided (RFC 1034 section 5.2.2) so only tell your end users to use your chosen domain name as their CNAME DNS entry if your domain name is an ANAME to an IP address (or addresses)
  • Only use the CNAME method if your main domain is an ANAME of an IP address. This is very important. How do you know? Check your dns or ask your hosting company.
  • Giving your users the option to just use your chosen domain name and not an IP (or list of IP’s) to set as their CNAME will make administration of your WordPressMU blog platform or WordPress 3.0 network easier, an example of this would be purchasing/deploying a new server or indeed adding more servers to use in a round robin scenario. Your end users have no need to worry about IP address changes.
  • Finally, telling your end users to use an ANAME IP or CNAME domain name is up to you and how your systems are deployed.
  • Further Reading: http://www.faqs.org/rfcs/rfc2219.html

Create WordPress Multi user site

Creating WordPress Network Site

Admin Requirements

If you want to run a network of blogs you should at least have a basic understanding of UNIX/Linux administration. A basic knowledge of WordPress development, PHP, HTML and CSS is recommended as well.

Setting up and running a multi-site installation is more complex than a single-site install. Reading this page should help you to decide if you really need a multi-site install, and what might be involved with creating one. If the instructions on this page make no sense to you, be sure to test things on a development site first, rather than your live site.

Server Requirements

Since this feature requires extra server setup and more technical ability, please check with your webhost and ask if they support the use of this feature. It is not recommended to try this on shared hosting.

You are given the choice between sub-domains or sub-directories in Step 4: Installing a Network. This means each additional site in your network will be created as a new virtual subdomain or subdirectory.

  • Sub-domains — like site1.example.com and site2.example.com
  • Sub-directories — like example.com/site1 and example.com/site2

It is also possible later, through use of a plugin such as WordPress MU Domain Mapping, to map individual sites to independent domain names.

Sub-directory sites
It works with the use of the mod_rewrite feature on the server having the ability to read the .htaccess file, which will create the link structure.
If you are using pretty permalinks in your blog already, then subdirectory sites will work as well.
Sub-domain sites
It works using wildcard subdomains. You must have this enabled in Apache, and you must also add a wildcard subdomain to your DNS records. (See Step 2 how to set up.)
Some hosts have already set up the wildcard on the server side, which means all you need to add is the DNS record.
Some shared webhosts may not support this, so you may need to check your webhost before enabling this feature.

WordPress Settings Requirements

  • Giving WordPress its own directory will not work in WordPress 3.0 with multisite enabled. It interferes with the member blog lookup.
  • You cannot create a network in the following cases:
    • “WordPress address (URL)” is different from “Site address (URL)”.
    • “WordPress address (URL)” uses a port number other than ‘:80’, ‘:443’.
  • You cannot choose Sub-domain Install in the following cases:
    • WordPress install is in a directory (not in document root).
    • “WordPress address (URL)” is localhost.
    • “WordPress address (URL)” is IP address such as 127.0.0.1.
  • You cannot choose Sub-directory Install in the following cases:
    • If your existing WordPress installation has been set up for more than a month, due to issues with existing permalinks. (This problem will be fixed in a future version. See Switching between subdomains and subfolders for more inforamtion.)

(See wp-admin/network.php for more detail)

Step 1: Backup Your WordPress

Your WordPress will be updated when creating a Network. Please backup your database and files.

Step 2: Setting Wildcard Subdomains

(If this is a Sub-directories Install, skip this step.)

Sub-domain sites work with the use of wildcard subdomains. This is a two-step process:

  1. Apache must be configured to accept wildcards.
    1. Open up the httpd.conf file or the include file containing the VHOST entry for your web account.
    2. Add this line:
      ServerAlias *.example.com
  2. In the DNS records on your server, add a wildcard subdomain that points to the main installation. It should look like:
    A *.example.com

If you can’t access httpd.conf and your server uses CPanel. Make a sub-domain named “*” (wildcard) at your CPanel (*.example.com). Don’t give names to subdomains at CPanel. If you can’t do that, contact your host.

If your server uses Plesk Panel. There are several steps that differ when setting up the server for wildcard subdomains on a server using Plesk Panel compared to a server using cPanel (or no control panel). This article Configuring Wildcard Subdomains for multi site under Plesk Control Panel‎ details all the steps involved. Although the instructions are comprehensive, the actual work only takes a couple of minutes.

If your server uses DirectAdmin panel. (2011.01) A. Click “User Panel” -> DNS Management -> add the following three entries using the three columns: * A 123.45.67.890 (Replace “123.45.67.890” with your website IP.) B. Click “Admin Panel” (If you have no “admin panel” ask your host to do this.) -> Custom Httpd -> yourdomain.com -> In the text input area, just paste and “save” precisely the following: ServerAlias *.|DOMAIN| (If you ever need to un-do a custom Httpd: return here, delete text from input area, save.)

External links:

Step 3: Allow Multisite

To enable the Network menu item, you must first define multisite in the wp-config.php file.

Open up wp-config.php and add this line above where it says /* That's all, stop editing! Happy blogging. */:

define('WP_ALLOW_MULTISITE', true); 

Step 4: Installing a Network

This will enable the Network menu item to appear in the Tools menu. Visit Administration > Tools > Network to see the screen where you will configure certain aspects of our network.

Tools Network SubPanel

Addresses of Sites in your Network
You are given the choice between sub-domains or sub-directories (if none of the above applies). This means each additional site in your network will be created as a new virtual subdomain or subdirectory. you have to pick one or the other, and you cannot change this unless you reconfigure your install. See also Before You Begin.

  • Sub-domains — like site1.example.com and site2.example.com
  • Sub-directories — like example.com/site1 and example.com/site2
Network Details
There are filled in automatically.

Server Address
The Internet address of your network will be example.com.
Network Title
What would you like to call your network?
Admin E-mail Address
Your email address.

Double-check they are correct and click the Install button.

You may receive a warning about wildcard subdomains. Check Setting Wildcard Subdomains.

Warning! Wildcard DNS may not be configured correctly!

The installer attempted to contact a random hostname (13cc09.example.com) on your domain.

To use a subdomain configuration, you must have a wildcard entry in your DNS. This usually means adding a * hostname record pointing at your web server in your DNS configuration tool.

You can still use your site but any subdomain you create may not be accessible. If you know your DNS is correct, ignore this message.

Step 5: Enabling the Network

The rest of the steps are ones you must complete in order to finish.

Tools Network Created

0. First, back up your existing wp-config.php and .htaccess files.
1. Create a blogs.dir directory under /wp-content/
This directory is used to stored uploaded media for your additional sites and must be writable by the web server. They should be CHOWNed and CHMODed the same as your wp-content directory.
2. Add the extra lines your WordPress installation generates into your wp-config.php file.
These lines are dynamically generated for you based on your configuration.
Edit the wp-config.php file while you are logged in to your sites admin panel.
Paste the generated lines immediately above /* That's all, stop editing! Happy blogging. */.
Remove the earlier placed define('WP_ALLOW_MULTISITE', true); line only if you wish to remove the Network menu in the admin area. You may choose to leave this to be able to access the .htaccess rules again..
3. Add the generated mod_rewrite rules to your .htaccess file, replacing other WordPress rules.
(If there isn’t one, then create it.)
These lines are dynamically generated for you based on your configuration.
4. Log in again.
Once the above steps are completed and the new wp-config.php & .htaccess files are saved, your network is enabled and configured. You will have to log in again. click “Log In” to refresh your Adminstration Panel. If you have problems logging back in, please clear your browser’s cache and cookies.

Step 6: Super Admin Settings

You will now see a new menu section called Super Admin. The menus contained in there are for adding and managing additional sites in your network. Your base WordPress install is now the main site in your network.

Go Super Admin > Options panel to configure network options, and then create sites and users.

Things You Need To Know

Here are some additional things you might need to know about advanced administration of the blog network.

User Access

By design, all users who are added to your network will have subscriber access to all sites on your network.

Also, site admins cannot install new themes or plugins. Only the Network Admin (aka Super Admin) has that ability.

Permalinks

While permalinks will continue to work, the main blog (i.e. the first one created) will have an extra entry of blog, making your URLs appear like domain.com/blog/YYYY/MM/POSTNAME.

This is by design, in order to prevent collisions with SubFolder installs. Currently there is no easy way to change it, as doing so prevents WordPress from auto-detecting collisions between your main site and any subsites. This will be addressed, and customizable, in a future version of WordPress.

Also note that the blog prefix is not used for static pages which will be accessible directly under the base address, e.g. domain.com/PAGENAME. If you try to create a static page in the first blog with the name of another existing blog, the page’s permalink will get a suffix (e.g. domain.com/PAGENAME-2). If you create a new blog with the slug of an existing static page, the static page will not be reachable anymore. To prevent this, you can add the names of your static pages to the blacklist so that no blog with this name can be created.

WordPress Plugins

WordPress Plugins now have additional flexibility, depending upon their implementation across the network.
  • Site Specific Plugins: WordPress Plugins to be activated or deactivated by an individual blog owner are stored in the pluginsdirectory. You need to enable the Plugins page for individual site administrators from Network > Options.
  • Network Plugins: WordPress Plugins stored in the plugins directory can be activated across the network by the super admin.
  • Must-Use Plugins: Plugins to be used by all sites on the entire network may also be installed in the mu-plugins directory as single files, or a file to include a subfolder. Any files within a folder will not be read. These files are not activated or deactivated; if they exist, they are used.

Categories and Tags

Global terms are disabled in WordPress 3.0 by default. You can use the Sitewide Tags WordPress Plugin or other similar Plugins to incorporate global tags on the portal/front page of the site or on specific pages or blogs within the network to increase navigation based upon micro-categorized content.

Switching between subdomains and subfolders

If you have had WordPress installed for longer than a month and are attempting to activate the network, you will be told to use Sub-domain sites. This is in order to ensure you don’t have conflicts between pages (i.e. example.com/pagename ) and sites (i.e. example.com/sitename ). If you are confident you will not have this issue, then you can change this after you finish the initial setup.

In your wp-config.php file, you’ll want to change the define call for SUBDOMAIN_INSTALL:

Use SubDomains
define( 'SUBDOMAIN_INSTALL', true );
Use SubFolders
define( 'SUBDOMAIN_INSTALL', false );

You’ll also have to change your .htaccess to the new setup. Be aware, you may have issues if you attempt this after being on one setup or the other for any length of time, so proceed with caution.

.htaccess and Mod Rewrite

Unlike Single Site WordPress, which can work with “ugly” Permalinks and thus does not need Mod Rewrite, MultiSite requires its use to format URLs for your subsites. This necessitates the use of an .htaccess file, the format of which will be slightly different if you’re using SubFolders or SubDomains. The examples below are the standard .htaccess entries for WordPress SubFolders and SubDomains, when WordPress is installed in the root folder of your website. If you have WordPress in it’s own folder, you will need to change the value for RewriteBase appropriately.

As a reminder, these are EXAMPLES and work in most, but not all, installs.

SubFolder Example

# 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 

SubDomain Example

# BEGIN WordPress RewriteEngine On RewriteBase / RewriteRule ^index.php$ - [L]  # uploaded files RewriteRule ^files/(.+) wp-includes/ms-files.php?file=$1 [L]  RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^ - [L] RewriteRule . index.php [L] # END WordPress