Contents
Configuring Custom Domains in WordPress Multisite
WordPress Multisite is a powerful feature that allows you to run multiple sites from a single WordPress installation. While subdomains or subdirectories are the default configurations, mapping custom domains to individual sites within the network provides a professional, brand-aligned experience. This article provides a comprehensive guide—covering prerequisites, step-by-step instructions, SSL considerations, troubleshooting, and best practices—to help you implement and manage custom domains on your Multisite network.
1. Understanding Domain Mapping
Domain mapping connects a custom domain (e.g., www.example.com) to a specific subsite in your network (e.g., site1.network.com). There are two primary approaches:
- Plugin-Based Mapping: Uses third-party plugins to handle URL rewriting and admin settings.
- Domain Mapping in Core: Since WordPress 4.5, domain mapping capabilities are built into core Multisite, reducing plugin reliance.
2. Prerequisites
- A WordPress Multisite installation (subdomain or subdirectory mode enabled).
Official Guide: Creating a Network - Access to your DNS management console (domain registrar or hosting control panel).
- Server configuration allowing wildcard domains or individual virtual hosts (Apache/nginx).
WP Developer Handbook: Domain Mapping - SSL certificate for each custom domain or a wildcard certificate.
3. DNS Configuration
Proper DNS records ensure your custom domain points to your Multisite server IP. Use either a wildcard record or individual A/CNAME records:
Record Type | Host/Name | Value | Use Case |
---|---|---|---|
A | @ or site1 | 123.45.67.89 | Direct mapping for apex or subdomain |
CNAME | www | network.com | Alias pointing to primary domain |
A (wildcard) | 123.45.67.89 | Catches all subdomains |
4. Enabling Domain Mapping in Core
- Enable Multisite: Add
define(WP_ALLOW_MULTISITE, true)
to wp-config.php. - Follow the network setup instructions (subdomain/subdirectory mode).
- Ensure
SUNRISE
is set only if using legacy plugins otherwise skip:define(SUNRISE, on)
in wp-config.php.
- Network Admin → Sites → Edit a site → Site Address (URL): enter your custom domain (e.g., https://www.example.com).
5. Plugin-Based Mapping (Optional)
If you prefer a GUI and advanced features (redirect management, SSL automation), consider a plugin:
- WordPress MU Domain Mapping: Lightweight, widely used. Plugin Page.
- Mercator: Modern alternative supporting IPv6, WP-CLI. GitHub Repository.
General installation steps:
- Upload plugin to wp-content/plugins and network‐activate.
- Configure settings under Network Admin → Settings → Domain Mapping.
- Add each domain to its corresponding subsite via Sites → Edit → Domains.
6. SSL Certificate Management
Secure custom domains with TLS/SSL. Choose one of the following:
- Wildcard Certificate: Covers .network.com but not external domains.
- Individual Certificates: One certificate per mapped domain. Use Let’s Encrypt for free automation.
- SAN Certificate: Single certificate listing multiple domains in SAN fields.
Implement via your web server:
- Apache:
ltVirtualHost :443gt ServerName www.example.com SSLCertificateFile …lt/VirtualHostgt
- nginx:
server { listen 443 server_name www.example.com ssl_certificate … }
7. Advanced Considerations
7.1 Session Cookies Cross-Domain
To maintain admin sessions across domains, add in wp-config.php:
define(COOKIE_DOMAIN, false) define(ADMIN_COOKIE_PATH, /) define(COOKIEPATH, ) define(SITECOOKIEPATH, )
7.2 Email Delivery
Custom domains must align with your mail service to avoid SPF/DKIM/DMARC issues. Update DNS with:
- SPF record:
v=spf1 include:yourmailprovider.com -all
- DKIM and DMARC as per provider instructions.
8. Troubleshooting Common Issues
- 404 Not Found: Verify DNS propagation and web-server virtual host mapping.
- Mixed Content: Ensure https:// is forced network-wide (Network Admin → Settings → HTTPS).
- Login Redirect Loop: Clear browser cookies confirm
COOKIE_DOMAIN
settings. - Admin Bar Missing: Check if
DOCUMENT_ROOT
is correctly set in server config.
9. Best Practices
- Plan domain naming conventions centrally to avoid conflicts.
- Use automated SSL tools (Certbot, acme.sh) for renewals.
- Document each site’s DNS settings and SSL expiration dates.
- Regularly update WordPress core, themes, and plugins for security.
- Monitor DNS propagation and certificate health via uptime services.
10. References
|
Acepto donaciones de BAT's mediante el navegador Brave 🙂 |