ses routes based on url?

Is there a way to have different ses routes depending on the baseurl?

not sure if this is the best way to handle this but I put simple IF statements in the Routes.cfm under config directory.

if(cgi.http_host eq ‘URL_NAME_HERE’){


Jeremy R. DeYoung

If the two different domains used different ColdFusion applications, probably. routes.cfm is just a ColdFusion file, so you can put if statements and things in it, but it is only parsed once so whatever domain was used to init the framework would be the settings used.

Are you wanting to re-use the same code-base for two different apps, or have the same app accessible by two different URLs (and behave different based on that URL)?


I’m not trying to change the baseUrl. I’m trying to add different routes. I tried a simple if then around my add route statements but I guess since the add route statements process when the coldbox loads it’s not behaving as expected.

<cfif cgi.HTTP_HOST eq “”>
one set of addRoute statements

some other set of addRoute Statements

I’m doing this because if the website has a custom url the first parameter in the list isn’t needed, I calculate it from the url.

For example:

where as

I don’t need teamid because I have a function that looks up the teamid based on the custom domain name.

I have one other page that has some additional variables.

Thanks for any help.

Can you just set up both set of routes and look up teamID based on URL when you can. If someone hits the default domain and there is no teamID passed in throw an error (or do whatever you want to deal with it). Depending on the position of the items in the route, you should be able to do optional items with the “?” I think.

Routes aren’t used to generate links so I assume the onus is on you to make sure you supply the teamID when using the default domain.



Yes, you can do this.

Try setting routes with the addRoute method using a pattern like this:


Then, add a function called PathInfoProvider() to your routes.cfm file. You can read a little about the PathInfoProvider method here:

The PathInfoProvider method, if it exists, will be executed by the ColdBox SES Interceptor to get the CGI.PATH_INFO used to match routes. Using this function, you can inspect the host name and return a modified path_info value that will only match based on the proper domain.


function PathInfoProvider(Event){
var rc = Event.getCollection();
var prc = Event.getCollection(private=true);
// … stuff here …
case ‘domain1’ :
return ‘/domain1#cgi.path_info#’;

// … stuff here …

// … stuff here …



Thank you very much. This is exactly what I needed. If I get a chance to meet you at a CF event, dinner and beers on me. Thanks.