Halloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan NowHalloween DealsAmazon USOctober picks are moving - compare before checkoutAmazon US: current deals, useful picks and tech finds.See Picks×
FREEDOM251

Freedom251 › Blog › Apache

How to Add Another Domain to a WordPress Server With Virtual Hosts

By Freedom251 Team · · 11 min read

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

To add a second domain, point its DNS records at the server, route that hostname to the correct WordPress directory with an Apache VirtualHost or Nginx server block, secure it with HTTPS, and then update WordPress if the domain belongs to a Multisite site. The correct configuration depends on whether the domain should show the existing site, run a separate installation, or identify a separate site in one Multisite network.

What adding a domain actually involves

A domain name does not automatically select a WordPress site. Four layers must agree:

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.
  • DNS: the new hostname resolves to the server’s public IPv4 or IPv6 address.
  • Web-server routing: Apache or Nginx matches the hostname and sends the request to the intended document root.
  • WordPress: the installation, site URL, and rewrite rules accept that hostname.
  • TLS: the HTTPS certificate covers the new domain, including its www variant if you plan to use it.

WordPress describes the relationship directly: DNS maps the domain to the server IP, while the server maps the domain to the WordPress installation directory. See the WordPress network preparation guide.

If any layer is missing, visitors may see the old site, a default server page, a certificate warning, a redirect loop, or a 404. Build and test the layers in that order.

#1 Best Overall
Sale
TOZO A1 Wireless Earbuds Bluetooth 5.3 Light Weight in Ear Headphones | IPX5 Waterproof,2 Mics for AI Calls,Immersive Premium Sound Bass Headset with Charging Case,32 EQ via App Black
  • [Ultra-Lightweight Ear Buds Designed for Small Ears] Each earbud weighs only 3.7g and features a compact, ergonomic in-ear design made especially for small ears. Secure, low-profile, and comfortable for workouts, all-day wear or overnight sleeping.The ultra-slim profile sits flush in your ear with no hard edges poking or rubbing, so you can even sleep on your side without discomfort.
  • [Immersive Stereo Sound with TOZO OrigX Technology] TOZO OrigX tuning delivers clear vocals, balanced mids, and natural stereo sound for music, podcasts, and videos.
  • [Long Battery Life for Daily Use] Get up to 7 hours of playtime on a single charge, with up to 32 hours total using the charging case—ideal for workdays, commuting, and extended listening sessions.
  • [Bluetooth 5.3 & Stable Connection] Bluetooth 5.3 provides fast pairing, stable wireless performance, and reduced dropouts as you move around home or office.
  • [Deep Bass with Clear Vocals] High-performance drivers produce punchy bass while keeping vocals clean and detailed for everyday listening.

Choose the right site model first

Decide what the second domain is supposed to represent before editing a virtual host. The choice changes your document roots, databases, WordPress settings, and maintenance responsibilities.

Goal Server arrangement WordPress arrangement Best fit
Another address for the existing site Route both hostnames to the same document root One installation; configure the preferred canonical URL and redirects An alias, rebrand, or migration address
A completely independent site Give the domain its own document root and virtual host/server block Separate WordPress files and database Sites that need independent plugins, administrators, updates, or backups
A separate site sharing one WordPress codebase Route the domain to the Multisite installation and apply Multisite rewrite rules One network with separate site tables and uploads Organizations managing several related sites centrally

Multisite sites share WordPress core files but retain separate site data structures and upload directories. The network creation documentation also requires choosing subdomain or subdirectory mode when the network is created. Domain mapping changes the public hostname; it does not turn an ordinary single-site installation into a network.

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

Prerequisites and access

  • Control of the new domain’s DNS zone, or a DNS administrator who can create records for you.
  • Shell and elevated privileges for the server, or a hosting control panel that exposes virtual-host/server-block settings.
  • The intended WordPress document root, database details, and PHP-FPM socket or upstream name when using Nginx.
  • Permission to reload Apache or Nginx after validating configuration.
  • A plan for certificates covering the exact hostnames visitors will use.
  • A recent backup of WordPress files and databases before changing URLs, rewrites, or Multisite settings.

Shared hosting that does not expose DNS or web-server configuration may require the host’s domain-addition workflow instead of manual virtual hosts. Do not edit system configuration you cannot reload or recover.

1. Point the new domain at the server

Create an A record for the apex name (for example, example.net) pointing to the server’s public IPv4 address. If the server has IPv6, create an AAAA record as well. Add a www record if that hostname will be accepted; it can be another A/AAAA record or a CNAME to the apex, depending on your DNS provider.

Do not point DNS at a private address such as 192.168.x.x. If a reverse proxy, load balancer, or CDN terminates traffic first, use the public endpoint specified by that service and ensure it forwards the Host header.

DNS changes are cached according to the records’ TTL. Verify from more than one network before assuming the server is at fault:

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Sale
Smart Watch for Men Women Compatible with iPhone Samsung Android Phone 1.69 inch Full Touch Screen IP68 Waterproof Bluetooh Fitness Tracker Heart Rate/Sleep Monitor (Black)
  • 【IP68 Waterproof Multifunctinal Smart Watch】Torjalph fitness activity tracker smart watch is IP68 waterproof technology ,you can wear it when swimming,handwashing,it's rain-proof which means that you perform multiple exercise modes outside without worrying about sweat or rain corroding your fitness smart watch,and this watch equipped with a 230 mAh large capacity battery magnetic charging ,and this sports activity tracker watch can be used 5-7 days If fully charged.
  • 【Larger 1.83'' Full Screen Watch & Multi-dial Selection】1.83 inch full HD color touch screen smart watch for men / women provides excellent 240*284 resolution image quality ,This Bluetooth smart watch offers a better touch experience and remarkable immersion and ,more than 200 watch faces for you to choose from App"Da Fit ", you can change the dial style according to your mood to wear keeping the world on your wrist
  • 【Accurate Activity Tracker Smart Watch 】sports watch activity tracker uses sweat and dust resistant breathable silicone strap, our Fitness Tracker Smart Watch for Android iOS Phones supports 12 sports modes,walking,running,bicycle,swimming,badminton,basketball,football,rope skipping. This bluetooth calls smart watch for men women is lightweight and stylish, bringing more convenient and relaxing sports experience while also providing more protection.
  • 【Your 24 Hour Personal Daily Health Monitor】Fitness watch for women men full touch screen IP67 waterproof bluetooth smartwatch for Android iOS Phones with heart rate blood pressure monitor multifunction Andriod smart watch with steps counter sleep monitor sports fitness watch, monitoring blood oxygen saturation allows you to understand your physical condition in real time to track fitness progress ,to know your health status in time.
  • 【More Functions Bluetooth Call Smart Watch】This fitness activity smart watch full screen for iPhone and Android phones includes a bunch of new features including:The bluetooth smart watch can hang up the phone, receive and display WhatsAPP /Text /Facebook /Twitter /Messenger reminder.Support sedentary reminder, alarm clock, stopwatch, timer,weather information,music control, remote camera control compatible with Android 5.0 and above or iOS 9.0 and above smartphones.
dig +short example.net A
dig +short example.net AAAA
dig +short www.example.net A

The returned addresses should be the public addresses that accept web traffic. DNS only gets the request to the machine; it does not select a WordPress directory.

2. Add an Apache VirtualHost

Apache matches the request’s Host header against ServerName and ServerAlias. Create a separate file for the domain, point DocumentRoot at the correct WordPress directory, and make sure the directory permits WordPress rewrites. WordPress’s preparation guidance calls out virtual hosts, mod_rewrite, and suitable AllowOverride settings.

Independent WordPress installation

For a separate site, use a distinct directory such as /var/www/example.net/public. A typical HTTP virtual host is:

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

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

    ErrorLog ${APACHE_LOG_DIR}/example.net-error.log
    CustomLog ${APACHE_LOG_DIR}/example.net-access.log combined
</VirtualHost>

Use the path that contains that site’s wp-admin, wp-content, and wp-includes directories. If you intentionally use a shared installation, point the virtual host at that shared directory instead, but do not expect two independent databases to work from one ordinary single-site configuration without additional architecture.

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

Enable rewriting and the site

On distributions that use Apache’s site-management helpers, enable the rewrite module and the new site, then validate and reload. Names differ by operating system, so use your distribution’s service tooling:

sudo a2enmod rewrite
sudo a2ensite example.net.conf
sudo apachectl configtest
sudo systemctl reload apache2

apachectl configtest must report a successful syntax check before you reload. On systems without a2ensite, place the configuration in the directory Apache includes and reload the service through that system’s documented command.

Rank #3
New Bee Guitar Cable 10ft Electric Instrument Bass AMP Cord | 6.35mm Jack, Durable Design, Stage and Home Studio Use, Low Noise Shielded Electric Cord for Bass, Keyboard, Amp, Mixer
  • [Low Noise High Fidelity] New bee guitar cord with 22AWG oxygen-free-copper center conductors provides enhanced signal transfer, the PVC insulation material and the high-density stranded copper double shield provide noise rejection for quiet operation
  • [Ideal for Choice] New bee 1/4 straight and right angle metal connectors, ensures a secure connection in any instrument, pedal, or amp jack. L shape great fro on stage guitar stands
  • [Wide Compatible] Suitable for mixer, power amplifier, microphone, effector, decoder, equalizer, electoronic organ, electric guitar, electric bass and other electronic equipments. Widely used in the installation of smart home, karaoke speaker, professional stage audio, etc
  • [Easy Disassemble] Making incidental repairs quick and easy! Very nice, flexible cable
  • [Dont Hesite to Order] 24 hours customer services and professional technology team are standing by

When .htaccess is not being read

WordPress normally writes its Apache rewrite rules to .htaccess. If pretty permalinks return 404 while the home page works, check that AllowOverride All (or at least the required override classes) applies to the document root, that mod_rewrite is loaded, and that the file is readable by Apache. Avoid placing broad overrides on a parent directory that contains unrelated sites.

3. Add an Nginx server block

Nginx does not read Apache .htaccess files. Its rewrite and PHP handling must be written in the Nginx configuration itself. WordPress also notes that it can generate Apache and IIS rules but cannot generate Nginx configuration; use the official Nginx guidance as the reference for your PHP version and network mode.

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.

Single-site or independent installation

Set the new hostname in server_name, point root to the intended WordPress directory, and use a try_files fallback to index.php. Pass PHP requests to the PHP-FPM socket or upstream configured on your server:

server {
    listen 80;
    listen [::]:80;
    server_name example.net www.example.net;
    root /var/www/example.net/public;
    index index.php;

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

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php-fpm.sock;
    }
}

The socket path in this example is illustrative; use the PHP-FPM pool actually installed on your server. Some distributions use a versioned path such as /run/php/php8.x-fpm.sock, while others define a named upstream. Check the pool configuration instead of guessing.

Place the block in the directory included by your main Nginx configuration, test it, and reload only after a successful test:

sudo nginx -t
sudo systemctl reload nginx

Multisite on Nginx

A Multisite network needs the network-specific rewrite rules in addition to the hostname and PHP settings. Subdomain and subdirectory networks use different rules, so copy the variant that matches the mode selected when the network was created. Confirm that uploaded media paths and administrative URLs are handled by the same server block. Never copy Apache directives such as AllowOverride into Nginx; they have no meaning there.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
BSIMB 15.6" Digital Family Calendar & Chore Chart, No Subscription Fees
  • Digital Family Calendar: BSIMB digital calendar wall touch screen puts an end to your chaotic life. Designed for busy families, the digital calendar keeps you organised and in step with your family. Assign different colours and tasks to each family member to make family scheduling easier and more intuitive.
  • Easy Setup and Auto-Sync: Plug in, connect to WLAN and auto-syn your electric calendar in minutes. Digital wall calendar compatible with Google calendar, iCloud calendar, Outlook calendar, Cozi calendar and Yahoo calendar. Add events directly on the device or through the ecalendar app. Electronic calendar stays current whether you're at work or traveling—no manual updates needed.
  • All-In-One Home Assistant: Smart calendar builds habits and encourage independence with personalised chores. Display daily meal plan to reduce the daily ‘What's for dinner?’ stress. To-do lists keep track of everything you want. Turning chores into valuable achievements with stars and rewards, making life easier and more enjoyable.
  • Manage Anytime Anywhere: BSIMB electronic calendar for family stay connected with the powerful ecalendar app. Access and manage your digital wall calendar anytime, anywhere with free features like stars & rewards, photo screensaver, chore charts, meals plans, to-do lists etc. Electronic planner paid features like Magic Import tailor advanced tools for users with special needs.
  • Stay in Touch with Loved Ones: Share photos or videos from your phone to electronic wall calendar with app, instantly update your life moment, and keep in touch with your family, especially those who are far away; you can also surprise your smart calendar digital wall by sending him a wish card; it's also great for keeping tech-illiterate elders in touch with the youngsters.

4. Install HTTPS for the added hostname

Obtain a certificate whose names cover every hostname you serve. If visitors can use both the apex and www, include both or redirect one only after the certificate covers the initial request. WordPress’s domain-mapping guidance recommends SSL for the primary and mapped domains and identifies Server Name Indication (SNI) for multiple domains; see WordPress Multisite Domain Mapping.

Whether certificates are issued by an automated ACME client, your host, or another certificate authority, the operational sequence is the same:

  1. Make sure DNS resolves and port 80/443 traffic reaches the correct server or proxy.
  2. Request a certificate for the exact domain names.
  3. Add an HTTPS virtual host or server block that uses the certificate and key.
  4. Test the configuration, reload the web server, and then redirect HTTP to HTTPS.
  5. Check that WordPress’s home and site URLs use https:// and that no images, scripts, or forms still load over HTTP.

SNI lets one server present different certificates based on the requested hostname. It requires a modern client and a web server configured with each certificate; it is not a substitute for adding the hostname to the certificate.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

5. Map the domain in WordPress Multisite

Use this section only when the new domain identifies a site inside an existing Multisite network. Finish DNS, web-server routing, and TLS first so the mapped URL is reachable before you change the database-backed site address.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  1. Sign in as a network administrator and open Network Admin → Sites.
  2. Choose the site to map and select Edit.
  3. On the site settings screen, replace the full Site Address (URL) with the mapped URL, for example https://example.net. Include the scheme and do not add a trailing path unless that path is genuinely part of the site.
  4. Save the change, then test the front end, /wp-admin/, media, and permalinks while signed out and signed in.

Native domain mapping is available in WordPress 4.5 and later. Older versions required a domain-mapping plugin. The network’s original address remains important for network administration, cron jobs, and recovery, so record it before changing any site address.

Blocked-cookie login errors

If mapped-domain logins report that cookies are blocked even though the browser accepts cookies, check for inconsistent HTTP/HTTPS hosts, proxy headers, and mixed domains. The official mapping guide documents this possible configuration adjustment:

define( 'COOKIE_DOMAIN', $_SERVER['HTTP_HOST'] );

Apply it only after understanding the effect on every site in the network and testing an administrator account. A malformed wp-config.php edit can lock out all network sites, so keep a console or file-based recovery path.

6. Configure a separate, non-Multisite WordPress site

If the new domain is independent, install WordPress in its own document root and create a separate database and database user. During installation, set the site URL to the HTTPS hostname you intend to keep. Do not point two unrelated databases at one directory and assume the virtual host alone separates them; WordPress reads its database and configuration from the files it loads.

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

Give the web-server user access to the new site’s files, but keep database credentials and wp-config.php protected from web downloads. Enable automatic updates and backups independently if the sites have different owners or risk profiles. A separate installation makes plugin conflicts less likely, at the cost of separate updates, monitoring, and resource usage.

7. Verify every layer

Test from an external network, not only from the server itself. Work through this checklist:

  • DNS: A and AAAA lookups return the intended public addresses; remove stale records that send traffic elsewhere.
  • Host routing: the response is from the intended virtual host, not the first/default host in the configuration.
  • Status codes: HTTP and HTTPS return the expected 200 or intentional redirect, without an endless redirect chain.
  • Certificate: the certificate’s names include the hostname in the browser address bar, and the chain is trusted.
  • WordPress URL: the home page, canonical redirects, feeds, REST endpoints, and login all use the chosen scheme and hostname.
  • Permalinks: a non-home page loads directly, not only after visiting the front page.
  • Media: existing images and new uploads use the mapped domain and remain accessible over HTTPS.
  • Isolation: an independent site cannot read or serve another site’s files, and the mapped Multisite site lands on the intended site ID.
  • Logs: access and error logs for the new host show the requests, PHP errors, and upstream failures you expect.

Useful HTTP checks include:

curl -I http://example.net
curl -I https://example.net
curl -I https://www.example.net

Run these with the exact hostnames users will enter. A successful response from the wrong site is a routing error, not proof that the setup is complete.

Common failures and precise fixes

Symptom Likely layer What to check
The old site appears DNS or virtual-host order Confirm the new hostname resolves to this server, then verify ServerName/server_name and that the request is not falling through to the default host.
A generic Apache or Nginx page appears Host matching Check that the configuration file is enabled or included, the hostname is spelled identically, and the service was reloaded after a successful syntax test.
Browser certificate warning TLS Issue a certificate containing the exact apex or www hostname being requested; confirm the HTTPS host serves that certificate rather than the default one.
Pretty-permalink 404s on Apache Rewrite support Enable mod_rewrite, verify AllowOverride, and resave Settings → Permalinks after correcting access to .htaccess.
Pretty-permalink 404s on Nginx Server block Use the WordPress try_files fallback and ensure the request reaches the correct PHP-FPM upstream. Nginx will not read .htaccess.
PHP source downloads or returns 502 PHP-FPM Check the configured socket/upstream, PHP-FPM service status, file permissions, and the Nginx error log.
Multisite redirects to the old domain Site mapping or cached URLs Confirm the full Site Address in Network Admin, clear page/browser caches, and inspect canonical and HTTPS redirect rules.
Login says cookies are blocked Cookie host or scheme Use one consistent HTTPS hostname, check proxy headers, and consider the documented COOKIE_DOMAIN adjustment only after testing network-wide effects.

Security and maintenance after the change

  • Redirect the non-canonical hostname to one canonical HTTPS URL instead of serving duplicate content indefinitely.
  • Keep the certificate renewal process monitored; an expired certificate breaks both visitors and administrative access.
  • Limit database users and file permissions per independent installation. Do not make every site directory writable by unrelated service accounts.
  • Back up each database and upload directory, and test restoration before changing domain URLs again.
  • Document the DNS records, document root, virtual-host file, PHP-FPM pool, certificate names, and rollback procedure.
  • After plugin or WordPress updates, retest both the mapped domain and the network’s original administrative URL.

The WordPress server-configuration documentation is a useful reference when your host, PHP version, or web-server layout differs from the examples above.

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

When to stop and ask the host

Use the hosting provider’s support channel when you cannot edit DNS, cannot create a virtual host/server block, cannot reload the web server, or are behind a managed proxy that controls certificates and Host headers. Ask them to confirm the domain’s DNS target, document root, HTTPS certificate coverage, and whether the request reaches Apache or Nginx. Those are the four facts needed to continue troubleshooting without guessing.

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.

ApacheDNSHTTPSmultisiteNGINXvirtual hostsWordPress

Leave a Reply

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

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

Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
PC Slower Than It Used to Be?Free scan - under a minute

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.