Blog

ColdBox Free Tip 6 - Using Routing with Wildcard Domains!

Maria Jose Herrera December 18, 2024

Spread the word

Maria Jose Herrera

December 18, 2024

Spread the word


Share your thoughts

102 ColdBox Tips and Tricks by Luis Majano

Domain-Specific Routing with ColdBox!

ColdBox gives you the flexibility to create domain-specific routes, making it perfect for multi-tenant applications or projects that need to respond differently based on the domain or subdomain being accessed. In this tip, we’ll dive into how to use the withDomain() method to create routes that match specific domains or sub-domains.

Domain-Specific Routing

By using ColdBox's withDomain() method in your router, you can define routes that match against incoming domains. This is incredibly useful for multi-tenant applications, where each client has its own subdomain, or any project where domain-based routing is needed.

How to Use withDomain() in Routing

Here’s an example of how you can use domain-based routing in ColdBox:

route( "/" )
  .withDomain( ":client.myapp.io" )
  .to( "client.show" );

In this case, the :client placeholder in the domain will be dynamically filled with the subdomain, and the value will automatically be available in the Request Collection (rc).

For example:

  • Request URL: ortus.myapp.io
  • rc.client: ortus

This makes it easy to handle different client subdomains dynamically in your SaaS or multi-tenant application.

Why Use Domain-Specific Routing?

  • Multi-tenant Support: Perfect for applicatios where each tenant has a unique subdomain.
  • Dynamic Routing: Allows you to dynamically extract domain values and use them in your logic (e.g., to load specific client data).
  • Flexibility: The withDomain() method supports placeholders and wildcards, giving you total control over how domains are routed.

With ColdBox, creating powerful domain-specific routing is a breeze. This feature makes managing multi-tenant apps or subdomain-based routing much simpler. Try it out in your next project!

Learn More ColdBox Tips and Tricks

Stay tuned for more ColdBox tips in our ongoing series. if you want to learn more than 10 free tips and tricks make sure to get your “ColdBox 102 tips and tricks book” We have a variety of formats you can choose from.

Get your Copy

Add Your Comment

Recent Entries

BoxLang AI 3.6: Your Agent Now Has Eyes, Ears, and a Voice

BoxLang AI 3.6: Your Agent Now Has Eyes, Ears, and a Voice

Ortus Solutions today announces BoxLang AI 3.6, the release that connects the AI framework to the rest of the BoxLang productivity platform. Your agents can now drive a real browser via bx-playwright, speak and master audio via bx-audio, stream text-to-speech token by token, talk to any MCP server over stdio — and do all of it with the same fluent BoxLang syntax they always have.

Luis Majano
Luis Majano
October 20, 2026
BxAudio 1.0: Make, Mix, Master and Speak Audio from BoxLang

BxAudio 1.0: Make, Mix, Master and Speak Audio from BoxLang

Ortus Solutions today announces the general availability of BxAudio 1.0, the audio module for BoxLang. Synthesize instruments and drums, arrange them on a beat grid, master to a loudness target, speak text with open license voices, score a video and play sound in a game. All of it from BoxLang, on the JVM. No Python. Nothing native to install.

Luis Majano
Luis Majano
October 20, 2026
BoxLang Under the Lens: Observability Meets AI - Free Webinar

BoxLang Under the Lens: Observability Meets AI - Free Webinar

Your application is slow. Something is failing. Where do you start looking?

On October 28, 2026, at 11:00 AM CDT, join Luis Majano, Ortus Solutions CEO and BoxLang creator, for a live, hands-on look at how observability and AI come together in BoxLang.

BoxLang Under the Lens: Observability Meets AI introduces BxLens, Lensy, and the additional monitoring capabilities of BoxLang+....

Victor Campos
Victor Campos
October 19, 2026