October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run ScanOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
VGSources
Blog

How to Add Another Domain to a WordPress Server With Apache or Nginx Virtual Hosts

Connect DNS, Apache or Nginx routing, HTTPS and WordPress settings to add another domain safely—whether it serves the same site, a separate install or a Multisite site.
Length9 min Posted Quest giverVGSources Team
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To add a second domain, connect three layers in order: DNS must send the hostname to your server, Apache or Nginx must route that hostname to the intended WordPress directory, and HTTPS plus WordPress must recognize the domain. WordPress describes the requirement as mapping the domain to the server IP in DNS and mapping the hostname to the WordPress installation directory on the server (WordPress Developer Resources).

Before editing configuration, decide whether the domain is an alias for the existing site, a completely separate WordPress installation, or another site in a WordPress Multisite network. Those choices determine the document root, database arrangement, URL settings and certificate configuration.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Choose what the second domain should serve

A virtual host (Apache) or server block (Nginx) selects a site by the hostname sent with each HTTP request. The same mechanism can expose one site under multiple names or isolate several sites on one server, but WordPress storage and URL settings differ for each model.

Another address for the existing site

Use the existing WordPress directory when both domains should display the same installation and content. Add the new hostname to the virtual host or server block that already serves the site. You still need a certificate covering the new name and should test canonical redirects, media URLs and administrator login under that hostname.

A separate WordPress installation

Give the new site its own document root and database. Create a dedicated Apache VirtualHost or Nginx server block that points only to that directory. This keeps files, uploads, plugins and database content independent from the first site.

A site in WordPress Multisite

Multisite sites share WordPress core files but maintain separate site data structures, tables and upload directories (Create A Network). Choose subdomain or subfolder network mode when creating the network, then map the additional domain to the desired site. Native domain mapping is available in WordPress 4.5 and later.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Model Server routing WordPress data Use it when
Existing site under another domain Point the additional hostname at the existing document root One installation and one site’s content Both domains should present the same site
Separate installation Create a new virtual host or server block and document root Independent files and database The second domain is an unrelated site
Multisite site Route the hostname to the network’s WordPress directory, then map it in Network Admin Shared core with separate site tables and uploads Several related sites should share one WordPress codebase

Prerequisites and access

You need control of the domain’s DNS zone, the server’s public IPv4 or IPv6 address, and permission to change Apache or Nginx configuration. A managed WordPress plan may not expose virtual-host files; in that case, the host must create the hostname mapping for you.

  • Identify the intended WordPress document root and, for Nginx, the PHP-FPM upstream or socket already used by the working site.
  • Record whether the server runs Apache or Nginx. The configuration methods are not interchangeable: Nginx does not read Apache .htaccess rules.
  • Back up the WordPress files, database and current web-server configuration before adding a host.
  • Plan a certificate for every hostname that will accept HTTPS. WordPress recommends SSL for the primary and mapped domains and identifies SNI as the method for serving multiple domains (WordPress Multisite Domain Mapping).

Point DNS at the server

Create an A record for the new name that contains the server’s public IPv4 address. If the server is correctly configured for IPv6, create an AAAA record as well. Add a separate record for www if that hostname must work; it can point directly to the server or use the DNS provider’s supported alias record.

DNS alone does not select a WordPress site. WordPress’s preparation guidance requires both DNS mapping to the server IP and server mapping from the hostname to the WordPress directory (Before You Create A Network). After saving the records, check that the new hostname resolves to the intended address from outside the server’s local network. Do not proceed with certificate issuance or browser testing while the hostname still resolves to an old host.

Configure an Apache virtual host

Apache chooses a VirtualHost using the requested hostname. Create a configuration file for the added domain in the distribution’s Apache configuration directory and point DocumentRoot to the correct WordPress directory.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

1. Define the hostname and document root

This is a minimal HTTP pattern. Replace the example names and path with the values for your server; keep the existing site’s security and logging directives where appropriate.

<VirtualHost *:80>
    ServerName example.net
    ServerAlias www.example.net
    DocumentRoot /var/www/example.net

    <Directory /var/www/example.net>
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

For an alias of the first site, use that site’s document root instead. For an independent installation, use the new directory and verify that its ownership and permissions allow Apache to read WordPress files and write only where WordPress requires it.

2. Make WordPress rewrites available

WordPress permalinks depend on Apache rewrite support. Enable the server’s rewrite module and ensure the directory settings permit the WordPress rules to operate; WordPress specifically calls out mod_rewrite and the required AllowOverride settings in its network preparation guidance (Before You Create A Network). If overrides are disabled, the home page may load while posts and administrative paths return 404 errors.

3. Enable and reload safely

Use the normal site-enable and configuration-reload tools for your Linux distribution. The exact command names differ between operating systems, so validate the configuration with the distribution’s Apache test command before reloading. Keep the old virtual host enabled until the new host answers correctly, and check that the new definition is not shadowed by a default host that appears earlier in Apache’s matching order.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

4. Add HTTPS after HTTP routing works

Once the hostname reaches the right virtual host over HTTP, add a port-443 virtual host using a certificate whose names include the new domain. Redirect HTTP to HTTPS only after the certificate and HTTPS routing have been tested; otherwise a redirect can hide whether DNS or the certificate is the actual problem.

Configure an Nginx server block

Nginx uses server blocks rather than Apache virtual hosts. It does not consume .htaccess, and WordPress cannot generate Nginx configuration automatically (Nginx; Multisite Network Administration). Every rewrite and PHP-handling rule therefore belongs in the Nginx configuration.

1. Define the name, root and front controller

The following pattern shows the essential routing. The PHP-FPM socket or upstream name is installation-specific; use the same configured upstream as the existing working WordPress site.

server {
    listen 80;
    server_name example.net www.example.net;
    root /var/www/example.net;
    index index.php index.html;

    location / {
        try_files $uri $uri/ /index.php?$args;
    }

    location ~ .php$ {
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_pass unix:/run/php/php-fpm.sock;
    }
}

For a second independent installation, point root to its own directory. For an additional domain on the same site, retain the existing root and add the hostname to that site’s server_name list or create a separate block with the same root, according to your server’s organization.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

2. Apply the correct Multisite rules

A Multisite network needs the Nginx rewrite pattern appropriate to its subdomain or subfolder mode. Copy the network’s required rules into the server block rather than expecting WordPress to create them. The official administration documentation notes that WordPress can generate Apache and IIS rules but not Nginx configuration (Multisite Network Administration).

3. Test and reload

Run the Nginx configuration test supplied by your operating system, correct every syntax error, and then reload Nginx through its normal service manager. If a request returns a 502 response, verify the PHP-FPM service and the fastcgi_pass socket or upstream before changing WordPress files.

Install HTTPS for the added domain

Obtain a certificate that explicitly covers the new hostname, including www if you intend to serve it. With multiple domains on one IP address, use Server Name Indication (SNI) so the web server selects the certificate matching the requested name. WordPress’s domain-mapping guidance recommends SSL for the primary domain and SNI for additional domains (WordPress Multisite Domain Mapping).

Install the certificate and private key in the HTTPS virtual host or server block, then test the site directly at https://example.net. Check that the browser reports the requested hostname, not merely a certificate that belongs to another site on the server. Update redirects and WordPress URLs only after HTTPS serves the intended content; otherwise you can create a redirect loop or mixed-content errors. Renew certificates before expiry and repeat the hostname check after each renewal.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Map the domain in WordPress Multisite

Server routing must be complete before you edit the network. If DNS, the virtual host and TLS are not ready, WordPress may save a URL that cannot be reached and make administrator access confusing.

1. Confirm the network mode

When the network was created, it was set up for subdomains or subfolders. That choice affects rewrite rules and the way new sites are initially addressed. A custom domain can still be mapped to a site, but the underlying network configuration must remain coherent.

2. Edit the site address

  1. Sign in to the WordPress Network Admin.
  2. Open Sites.
  3. Edit the site that should receive the new domain.
  4. Replace its complete Site Address (URL) with a value such as https://example.net, including the scheme and hostname.
  5. Save the change, then open the mapped URL in a private browser window and test both the front end and wp-admin.

Native domain mapping is supported in WordPress 4.5 and later. Older WordPress versions required a domain-mapping plugin, so do not follow the native procedure on an older installation without checking its version and compatibility (WordPress Multisite Domain Mapping).

3. Handle a blocked-cookie login

If login reports that cookies are blocked after mapping, the official guidance documents this possible configuration adjustment in wp-config.php:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
define( 'COOKIE_DOMAIN', $_SERVER['HTTP_HOST'] );

Apply it only when the mapped network has this specific cookie problem, and test administrator login on every mapped domain afterward. A cookie setting that fixes one hostname can break another if the network is not mapped consistently.

Verify the complete request path

Test in this order so each layer is isolated:

  1. Confirm the new hostname’s A and, if used, AAAA records return the server’s public addresses.
  2. Request the HTTP URL and verify that the response comes from the intended site, not the server’s default virtual host.
  3. Request the HTTPS URL and inspect the certificate hostname, chain and expiry.
  4. Open the home page, a post or page with a non-default permalink, an uploaded image and the login page.
  5. For a separate installation, confirm that files and content belong to the new site’s document root and database.
  6. For Multisite, confirm the mapped Site Address (URL) in Network Admin and verify that navigation stays on the mapped domain.
  7. Check canonical redirects, media URLs and permalinks. A redirect to the old domain usually indicates a WordPress URL or mapping mismatch; a 404 on pretty permalinks usually indicates missing rewrite rules.
  8. Review Apache or Nginx and PHP-FPM logs while making a request. The log entry should identify the new hostname and the expected upstream or document root.

Troubleshoot by symptom

Symptom Likely layer Corrective action
The domain opens an unrelated site on the server Virtual-host or server-block selection Check the hostname list, document root and ordering of enabled hosts. Ensure the request is not being handled by the default host.
The browser cannot connect DNS, firewall or listener Recheck the A/AAAA records and confirm Apache or Nginx is listening on the required HTTP or HTTPS port.
The home page works but pretty links return 404 Rewrite configuration On Apache, enable rewrite support and permit the WordPress override rules. On Nginx, add the try_files front-controller rule; .htaccess cannot fix Nginx.
PHP downloads or Nginx returns 502 PHP-FPM routing Verify the PHP-FPM service and make fastcgi_pass match the working socket or upstream. Check that the new root contains the intended WordPress files.
HTTPS shows the wrong certificate TLS/SNI configuration Install a certificate containing the requested hostname and ensure the port-443 host or server block declares that name.
Multisite redirects to the old URL Site mapping or canonical URL Confirm the complete HTTPS value in Network Admin under Sites, then retest redirects and media URLs.
Multisite login says cookies are blocked Mapped-domain cookie handling Use the documented COOKIE_DOMAIN adjustment only for this symptom, then test all mapped sites and administrator sessions.

Operational boundaries and ongoing maintenance

Virtual hosts require server-level access. If your provider gives you only a site dashboard and no Apache or Nginx controls, ask support to add the hostname, document root and certificate, or move the site to hosting that exposes those settings.

Keep a record of which domain maps to which document root, database and certificate. When a site changes servers, update DNS and the corresponding virtual host together; changing only one layer can send visitors to the wrong installation. Renew every certificate, review redirects after renewal, and retest front-end URLs, media and wp-admin whenever a domain or server configuration changes.

The reliable sequence is therefore: choose the site model, create DNS records, route the hostname in Apache or Nginx, install HTTPS, map the URL in Multisite when applicable, and verify every request path. Skipping any layer leaves the second domain pointing at the wrong content or inaccessible even though the other layers are configured correctly.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More quests from Patch Notes

  1. How to Set Up a RedM (RDR2) Server in 2026: License Key, txAdmin and server.cfg, Step by StepBlog11min
  2. Best RedM (RDR2) Server Hosting in 2026: Comparing Four Hosts on Slots, Memory and PriceBlog10min
  3. How to Host a Mindustry Server in 2026: server-release.jar, Port 6567 and the Commands That MatterBlog7min
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.