Skip to main content

Domain Mapping

Learning Focus

By the end of this lesson you will know how to map domains to virtual hosts, handle multiple domains per site, and troubleshoot incorrect routing.

What Domain Mapping Does

Domain mapping tells OpenLiteSpeed which virtual host should handle requests for a given hostname. When a request arrives at a listener, the server reads the Host header and routes it to the matching virtual host.

Configuring Domain Mapping

In WebAdmin

  1. Navigate to Listeners → select the listener
  2. Click Virtual Host MappingsAdd
  3. Set:
    • Virtual Host: select an existing vhost
    • Domains: comma-separated list of domains
  4. Save and Graceful Restart

Example Mappings

Domain(s)Virtual HostNotes
example.com, www.example.comexampleMain site with www alias
api.example.comapiSeparate API vhost
staging.example.comstagingStaging environment
*defaultCatch-all fallback

Multiple Domains on One Virtual Host

You can map multiple domains to a single virtual host by listing them with commas:

example.com, www.example.com, example.net

All three domains will serve the same site content.

Troubleshooting Wrong Routing

If requests go to the wrong virtual host:

# Check what the server returns for a specific Host header
curl -H "Host: example.com" http://your-server-ip/

# Compare with another domain
curl -H "Host: other.com" http://your-server-ip/
ProblemLikely CauseFix
Default page shows instead of siteDomain not mappedAdd mapping in Listener → Vhost Mappings
Wrong site content servedDomain mapped to wrong vhostFix the mapping entry
Works for one domain but not aliasAlias not in the mapping listAdd the alias domain
info

If the mapping is wrong, the server may return the wrong site even when DNS is correct. Always verify mappings after DNS changes.

Key Takeaways

  • Domain mapping routes requests to the correct virtual host based on the Host header.
  • List all domains (including www aliases) in the mapping entry.
  • If the wrong site loads, check the mapping first — it is the most common cause of incorrect routing.

What's Next

  • Continue to Contexts to learn about path-based rules within a virtual host.