October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix NowOctober 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 Set Up Multiple Domain Aliases on a Web Server

Learn how to connect multiple domains to one website by configuring DNS, Apache or NGINX hostname matching, HTTPS certificates, canonical redirects, and troubleshooting checks.
Length10 min Posted Quest giverVGSources Team
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Point every domain at the server in DNS, then tell the web server which hostnames belong to the same site. Apache matches aliases with ServerName and ServerAlias; NGINX lists them in one server_name directive. HTTPS adds a third requirement: the certificate selected for each connection must include every hostname visitors can enter.

Understand the three layers before changing configuration

A domain alias is not created by a virtual-host file alone. A browser first resolves a hostname through DNS, connects to an IP address, negotiates HTTP or HTTPS, and sends the hostname in the request. Your server then chooses a virtual host or server block that matches that name.

As an Amazon Associate I earn from qualifying purchases.

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.
  1. DNS: publishes where each hostname should connect.
  2. Web-server matching: maps the requested hostname to the site’s files or application.
  3. TLS and application behavior: supplies a certificate and ensures redirects, cookies, links, and security policies work for the chosen host.

All three layers must agree. A correct Apache or NGINX file cannot compensate for a missing DNS record, and a valid DNS record cannot make an uncovered HTTPS hostname secure.

Plan the aliases and decide what visitors should see

Write down every public hostname before editing the server. Include the apex domain, www variant, regional or legacy domains, and any hostname used by a game portal, API, download endpoint, or administration interface. For each one, choose whether it should display the site or redirect elsewhere.

#1 Best Overall
Sale
Gaoye Blue Light Blocking Glasses
  • BLUE LIGHT BLOCKING GLASSES: Our blue light glasses for women boast UV400 protection, blocking harmful blue rays from computer screens. With these bluelight glasses women, you can enjoy gaming, reading, or watching TV with no worries of eye strain.
  • EYE RELIEF: Our blue light glasses are engineered to reduce blurry vision or strain caused by prolonged screen time. These womens blue light glasses aid in better sleep by preventing blue light from disrupting your natural sleep cycle, helping you fall asleep faster and enjoy a more restful night's sleep, making them the perfect christmas present.
  • COMFORTABLE: Crafted from durable material, our trendy blue light glasses for woman or blue light glasses men ensure long-lasting comfort. The high-transmittance lenses accessories, gamer gifts for men, help keep your eyes relaxed. Perfect stocking stuffers, gifts for gamers men, christmas gifts for men, halloween costumes.
  • LIGHTWEIGHT: These clear blue light glasses feature a lightweight frame, meaning they’ll stay comfy for long-term wear. Perfect as blue blockers glasses for women or mens blue light glasses, these non-prescription fake glasses for men can be worn throughout the day. The blue light blocking glasses women feature polycarbonate HD lenses, which are anti-reflective and restore true color.
  • WORRY-FREE PURCHASE: If you experience any issues, our support team is ready to assist you quickly. These are the perfect costume glasses for cosplay dressing up.
Hostname type Typical purpose Recommended handling
Preferred canonical name The address you want shared and indexed Serve the application here
www or apex alternative Common visitor variation Redirect permanently or serve deliberately
Legacy brand or old domain Migration and bookmarked links Redirect after confirming ownership and certificate coverage
Service hostname API, assets, downloads, or status page Use a separate virtual host when isolation, headers, or logs require it
Wildcard subdomain Many predictable names such as per-user pages Use only when the application is designed for wildcard routing

There are two legitimate policies. A canonical redirect sends aliases to one preferred hostname with a permanent redirect. Serving the same site on every name keeps the requested host in the address bar, but the application must generate domain-correct URLs and cookies. Do not mix policies accidentally: redirect some paths while allowing other paths to remain on an alias unless that behavior is intentional and documented.

Create DNS records for every alias

Add records with your DNS provider before testing the web-server configuration. An A record maps a hostname to an IPv4 address; an AAAA record maps it to IPv6. A CNAME can point a hostname at another hostname where your DNS design and provider allow it, but the zone apex often cannot use a conventional CNAME.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  1. Create the record for the apex name, if applicable.
  2. Create records for each www, regional, legacy, API, or download hostname you intend to expose.
  3. Use both A and AAAA when the server is reachable over both protocols. Remove stale IPv6 records if the service is not actually configured for IPv6.
  4. Allow for DNS TTL and resolver caching. A newly changed record may not be visible everywhere immediately.

Check resolution from more than one network before blaming the web server. Confirm that each name returns the intended address and that a CNAME ultimately resolves to the same service. DNS only directs traffic; it does not select an Apache virtual host or NGINX server block.

Configure multiple aliases in Apache

Build the HTTP virtual host

Put the preferred hostname in ServerName and every alternate hostname in ServerAlias. A single name-based virtual host can answer all of them:

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

    <Directory /var/www/example>
        Require all granted
    </Directory>
</VirtualHost>

Use the actual document root, directory permissions, rewrite rules, proxy directives, and logging conventions used by your distribution. Keep unrelated sites in separate virtual-host files so their aliases cannot overlap accidentally.

Rank #2
Windex Gaming Cleaning Wipes, Pre-Moistened Wipes to Instantly Clean all Gaming Gear and Electronics, Resealable Packaging for a Freshness Lock, 25 count (Pack of 1)
  • WINDEX GAMING WIPES: effortlessly clean all your gaming gear and gaming electronics in one easy step with our new Windex Gaming Wipes
  • AMMONIA FREE: our ammonia-free formula is safe to use on all of your favorite gaming equipment like consoles, headsets, controllers, screens, keyboards, and more
  • PRE-MOISTENED WIPES: each wipe instantly removes dust, dirt, and stubborn smudges and fingerprints leaving a streak-free shine
  • ANTI-STATIC: great for cleaning and wiping down your gaming gear and electronics leaving behind no visible residue
  • COMPACT RESEALABLE PACKAGE: store your pack of Windex Gaming Wipes anywhere in your home for whenever a quick and easy wipedown is needed

Enable, inspect, and reload

  1. Save the file in the location used by your operating system, such as the enabled-sites directory on Debian-based systems.
  2. Enable the site using your platform’s normal mechanism.
  3. Run apachectl configtest and correct every syntax error before reloading.
  4. Run apachectl -S. This prints parsed virtual hosts, their address-and-port bindings, and the file order Apache will use.
  5. Reload Apache without stopping active connections.

Apache’s documentation notes that “Many servers want to be accessible by more than one name. This is possible with the ServerAlias directive.” It also cautions that configuring virtual hosts does not create DNS entries. Treat the DNS and Apache changes as separate deployment steps.

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

Prevent the wrong Apache site from answering

Apache first narrows a request by IP address and port, then compares the hostname against ServerName and ServerAlias. If no name matches, Apache uses the first virtual host listed for that address and port. That default can make a correctly resolved alias appear broken because the request displays another site.

Make the intended default explicit where your deployment needs one, and keep virtual-host files in a predictable order. Remove duplicate aliases from other sites. Inspect apachectl -S after every change rather than relying on file names alone.

Add the HTTPS virtual host

Create a matching *:443 virtual host and configure TLS according to your Apache version and distribution. The hostnames in the certificate must include the names users will request:

<VirtualHost *:443>
    ServerName example.com
    ServerAlias www.example.com example.net www.example.net
    DocumentRoot /var/www/example
    SSLEngine on
    SSLCertificateFile /etc/ssl/example/fullchain.pem
    SSLCertificateKeyFile /etc/ssl/example/privkey.pem
</VirtualHost>

Keep the certificate chain and private key paths consistent with your certificate-management process. Validate the configuration, reload Apache, and test each hostname independently. An HTTP redirect does not fix a certificate-name mismatch: the browser checks the certificate before it can safely follow that redirect.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
LISEN Cell Phone Stand Phone Holder for Desk, Office Decor Gadgets for Men
  • Ergonomic & Adjustable Design: Fight "text neck" and improve your posture. Designed for comfort, it offers an adjustable height (7.1in-8.5in) (1.4in adjustable range) and angle (5°-85°) Please note: cell phone stand is only 9 inches tall—the length of a standard pencil
  • Without blocking subtitles Perfect for office desk Tiktok Face Time Zoom video—this is the ultimate kitchen desk essential for phones! Perfect viewing experience while reducing neck back strain, A must-have for gamers streamers desk, and anyone who values both style and support!
  • Sleek & Stable Design fits Otterbox Case: Say goodbye to bent cables, tangles, and tip-overs! LISEN’s stylish adjustable desk phone holder features a built-in charging hole and smart cable management, keeping your phone secure and your workspace clutter-free cool gadgets for men
  • ANTI-SLIP DESIGN free hands: The under 10.00 items easy gadgets back and the bottom of this kitchen essentials for women are fully covered by anti-skid silicone, which LISEN stand up desk decor can provide maximum protection device from any scratches and slides
  • Your Perfect Viewing Companion:If your product arrives damaged or breaks within 365 days, reach out to LISEN for a quick and hassle-free solution. Struggling with assembly, like tightening the screw? We’ve got your back! Your experience matters to us. (Product including: phone Holder stand*1, screw*1, hexagon screwdriver*1, specification*1)

Configure multiple aliases in NGINX

Use one server block for exact names

List all exact hostnames in the same server_name directive when they should serve the same content:

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

    location / {
        try_files $uri $uri/ /index.html;
    }
}

Preserve the proxy, FastCGI, cache, upload, and security settings required by your application. If two names need different headers, authentication, rate limits, logs, or upstreams, use separate server blocks even if they currently share a document root.

Understand wildcard and regular-expression matching

NGINX accepts exact names, wildcard names such as *.example.com, and regular-expression names. Use a wildcard only for an intentional pattern; it does not mean “all domains.” Matching has defined precedence, so a specific exact name should be preferred when behavior must differ from a wildcard. Regular expressions can make configuration difficult to audit and should be limited to cases that truly need them.

Validate and reload safely

  1. Place the configuration in the directory included by the main NGINX configuration.
  2. Run nginx -t to test syntax and referenced files.
  3. Review the effective server blocks, listen addresses, and included files if a name appears to match unexpectedly.
  4. Reload NGINX only after the test succeeds.

For HTTPS, add a server block listening on port 443 with the appropriate TLS directives for your installed NGINX version:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
server {
    listen 443 ssl;
    server_name example.com www.example.com example.net www.example.net;
    root /var/www/example;
    ssl_certificate /etc/ssl/example/fullchain.pem;
    ssl_certificate_key /etc/ssl/example/privkey.pem;
}

Some modern deployments use additional TLS parameters or managed certificate includes. Keep those settings consistent with the platform’s current syntax rather than copying directives from an unrelated version.

Rank #4
Ledagic IC+RGBW USB Powered Led Light Bar with App & Remote Control, 2 Pack
  • Easy Installation: Our gaming lights have been designed to enhance your entertainment experience. Simply position the led light bar next to your TV or game console to create a game room environment with ease. They come with USB power and a 60 inch cord for direct mounting and mobility
  • Audio Syncing & Extensive Mode: The built-in high-sensitivity music sensor allows you to sync the TV led lights to your favorite music. Lights react and move to the beat of music, film and game audio, creating an incredible immersive sound and light experience – and all without the need for an additional hub. You can choose from 64+ patterns, including strobe, illusion, jump, energy, gradient, running, chasing, fluttering mode etc. Each mode can be applied to different scenes
  • 64+ Chasing IC+RGB & W Effect: The independent control design of IC+RGB and white all-in-one multifunctional rgbw led bar lights monitor backlight allows you to easily switch the led lights for desk between IC+RGB and white to enjoy a variety of lighting effects, you can choose white lighting mode with high brightness for better illumination when working, etc. Choose IC+RGB lighting mode when you need to create an entertaining atmosphere for the light show, 16 million colours of Color changing rgb light bar let you dance to the beat and create a dynamic party atmosphere
  • Dynamic and Dimmable Lights: 1%-full brightness free brightness adjustment gives you the flexibility to adjust dimmable led light bar for room decorations or a variety of occasions
  • USB Powered: USB light bars for room can be powered by powernank, usb charger, TV, Monitor, laptop PC mainframe, making behind TV led lighting bar easy to install in any location.TV led lights are powered by the TV usb interface / PC mainframe, can be turned on/off synchronously with TV / PC

Make HTTPS work for every hostname

Cover every browser-visible name

Every hostname that can appear in the address bar must be listed in the certificate selected for that connection. A multi-name certificate can contain separate domains, such as an apex name, its www form, and a second domain. Obtain and renew it as one certificate or as coordinated certificates according to your certificate authority and deployment process.

Know the limits of wildcard certificates

A wildcard certificate for *.example.com covers one subdomain level, such as play.example.com. It does not cover the bare example.com, and it does not cover a deeper name such as eu.play.example.com. Add those names separately or use a certificate set that explicitly includes them.

Understand SNI selection

Server Name Indication (SNI) lets multiple HTTPS virtual servers share an IP address. The client sends the intended hostname during the TLS handshake; the server selects a certificate and then uses the HTTP Host header to route the request. A missing or incorrectly ordered TLS server block can therefore produce the wrong certificate or site even when the HTTP configuration is correct.

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

Choose and implement canonical redirects

Redirect aliases to one preferred hostname

For legacy names, spelling variants, and search-index consolidation, return a permanent redirect from each alias to the canonical URL. Preserve the path and, where appropriate, the query string. Configure the redirect in the alias virtual host or server block so the request is redirected before application routing.

Test both HTTP and HTTPS aliases. The HTTPS alias still needs a certificate covering that alias because the TLS handshake occurs before the redirect response. Check that the target uses the desired scheme, hostname, and port, and that repeated requests do not bounce between names.

Best Value
Sale
HUANUO FlowLift™ Dual Monitor Stand, Fully Adjustable Gaming Monitor Desk Mount for 13–32″ Computer Screens, Full Motion VESA 75x75/100x100 with C-Clamp & Grommet Base, Each Arm Holds 4.4 to 19.8 lbs
  • Compatible with Wide Screens - To ensure compatibility with the dual monitor mount, your each monitor must meet three conditions at the same time: First, computer screens size range: 13 to 32 inches. Second, screen weight range: 4.4 to 19.8 lbs. Third, the back of the monitor screen must have VESA mounting holes with a pitch of 75x75mm or 100x100mm.
  • Regarding the compatibility with desks - Your desk must meet three conditions at the same time: First, desk material: Only wooden desks are recommended, plastic or glass desks cannot be used. Second, desk thickness range: 0.59" - 3.54". Third, the bottom of the desk should not have any cross beams or panels, as this will interfere with installation. We recommend carefully checking that your desk and monitors meets all above conditions before purchasing.
  • Dual C-Clamp Hold - Worried your dual monitors might wobble or slip? Our upgraded base uses a larger platform plus a dual C-clamp structure to lock the dual monitor arm firmly to your desk. Each arm safely keeps your screens steady while you type, click and game—no shaking, no sliding, just a clean and secure setup you can trust every day. It also provides Grommet Mounting installation choice, both options ensure stable and secure fixation for your 0.59" - 3.54" desk.
  • Full-Motion Adjustment For Comfortable View - Pull the screen closer when you’re deep in a spreadsheet, push it back to watch videos, or rotate to portrait for coding — moving everything smoothly with just one hand. The monitor stand offers +85°/-50° tilt, ±90° swivel and 360° rotation. Raise your monitor up to 15.75″ to support a healthy sitting posture. Whether you’re working from home, gaming through the night, or switching between video calls and documents, getting the screens to your natural line of sight helps relieve neck, shoulder and back strain so you can stay focused longer with less fatigue.
  • Keep Your Desk Organized: By lifting both screens off the desktop, this dual monitor stand opens up valuable space for your keyboard, notebook, docking station or a simple, clutter-free work area. Built-in cable management guides wires along the arms, keeping cords out of sight and out of the way. Enjoy a tidy, modern workstation that looks as good as it feels to use.

Serve the same site on every name only deliberately

If aliases remain visible, audit the application rather than stopping at the server configuration. Absolute links, image and script URLs, canonical tags, Open Graph metadata, password-reset messages, cookie domains, CORS allowlists, OAuth callback URLs, and API clients may all embed a hostname. A login cookie scoped to one domain will not automatically authenticate a different domain. Decide whether cross-domain sharing is safe before broadening cookie or CORS settings.

Test each alias from DNS through the application

  1. Resolve the name: query the relevant A, AAAA, or CNAME record and verify the returned address.
  2. Test HTTP routing: send a request with the intended Host header to the server address. This separates hostname matching from public DNS propagation.
  3. Test HTTPS by hostname: connect using each real hostname so SNI is sent, then inspect the certificate subject and alternative names.
  4. Check the response: confirm the expected status code, redirect target, content, cookies, and security headers.
  5. Read logs: compare access and error logs for unmatched hosts, redirect loops, certificate errors, upstream failures, and application-generated links.

Testing by IP alone is insufficient: it may select the default server and does not reproduce SNI behavior. Test the apex and every alias separately, including IPv6 if an AAAA record exists.

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

Troubleshoot the common failure modes

The alias resolves but shows another website

Check that the hostname appears exactly in Apache’s ServerName/ServerAlias or NGINX’s server_name. Confirm that the block listens on the address and port reached by DNS. Then inspect Apache’s apachectl -S output or the NGINX configuration for a duplicate name. If no block matches, the default or first-listed virtual host receives the request.

One alias works on HTTP but fails on HTTPS

Verify that port 443 has a matching server block and that the certificate includes the failing hostname. Check SNI by testing with the hostname rather than an IP address. A certificate containing only example.com will not validate www.example.com unless that name is also listed.

DNS checks disagree between networks

Allow for TTL and resolver caching, and verify that old A or AAAA records are not sending some clients to another server. During migration, keep the old endpoint available until caches have expired and the new endpoint has been tested.

Redirects loop or switch domains unexpectedly

Inspect server rewrite rules and application logic together. A proxy or load balancer may terminate TLS and forward a different scheme or host unless forwarding headers are handled consistently. Ensure only one layer owns canonicalization for a given request path, and confirm that the application trusts forwarded host and protocol headers only from known proxies.

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.

Links, cookies, or APIs use the wrong domain

Search configuration and generated responses for hard-coded absolute URLs. Update canonical metadata, asset URLs, password-reset templates, callback registrations, cookie attributes, and CORS policies to match the selected alias policy. Avoid setting a broad parent-domain cookie unless every subdomain is trusted.

Operational and security checks

  • Keep a written inventory of every DNS name, certificate name, virtual-host entry, owner, and intended policy.
  • Remove aliases that are no longer registered or controlled; otherwise a future registrant could receive traffic intended for your site.
  • Renew certificates before expiration and verify renewal installs the certificate on every relevant HTTPS block.
  • Log the original host and forwarded host separately when traffic passes through a proxy, but reject invalid or unexpected hostnames.
  • Use separate server blocks for administrative or sensitive services when they need different authentication, network restrictions, or security headers.
  • After configuration changes, test syntax first, reload gracefully, and retain a known-good rollback file.

Deployment checklist

  1. Choose the canonical hostname or explicitly approve serving all aliases.
  2. List every public hostname and the paths or services it should expose.
  3. Create and verify DNS records, including IPv6 records only when reachable.
  4. Add Apache ServerName/ServerAlias entries or the NGINX server_name list.
  5. Confirm the document root, proxy target, permissions, and application settings.
  6. Validate configuration with apachectl configtest or nginx -t.
  7. Inspect virtual-host or server-block selection, including the default for unmatched names.
  8. Install a certificate containing every hostname used over HTTPS.
  9. Reload the server and test HTTP, HTTPS, redirects, content, cookies, and generated links for each alias.
  10. Monitor logs and renewals after launch.

The Bottom Line

Multiple aliases work reliably when DNS records, hostname matching, TLS certificates, and application URLs are configured as one deliberate design. Apache uses ServerName/ServerAlias; NGINX uses server_name. Validate every name and make the default-server and canonical-redirect policies explicit.

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 *

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.