Hi everyone.
I have an application with two modules, organized like this:
/apps
+ /public
- ModuleConfig.cfc
this.name = "public";
+ /manager
- ModuleConfig.cfc
this.name = "manager";
this.entryPoint = "/manager";
I would like the “public” application to respond to the site root “http://$DOMAIN/”
and the “manager” application responded by writing “http://$DOMAIN/manager”.
This last application works fine, setting ModuleConfig.cfc with
this.entryPoint = "/manager"
I tried to set for the “public” app in ModuleConfig.cfc:
this.entryPoint = "/"
or
this.entryPoint = ""
but it does not work.
Is it possible to do what I ask?
Thank you.
You might consider a URL Rewrite. Assuming you are using CommandBox, below is the doc. Look at “customRewrites.xml”.
1 Like
Here’s a little function you can add to your module config, borrowed from ContentBox, which will assign the module routes as the root routes. You can just call it in the onLoad
of your public
module:
private function assignModuleRoutesToRoot(){
// get parent routes so we can re-mix them later
var routingService = controller.getRoutingService();
var parentRoutes = routingService.getRoutes();
var newRoutes = [];
// Keep non-convention routing
routingService.setRoutes(
parentRoutes.filter( function( item ){
return ( item.pattern NEQ ":handler/" AND item.pattern NEQ ":handler/:action/" );
} )
);
// Add parent execution routing
routingService.addRoute( pattern = "#variables.parentSESPrefix#/:handler/:action?" );
// Register UI routes now in take over mode.
variables.routes.each( function( item ){
// Check if handler defined
if ( structKeyExists( item, "handler" ) ) {
item.handler = "public:#item.handler#";
}
// add it as main application route.
routingService.addRoute( argumentCollection = item );
} );
// Point Default event to UI
controller.setSetting( "DefaultEvent", "public:index" );
}
2 Likes
Oh, thanks @jclausen!
It works like a charm 
I only changed the last line, from:
controller.setSetting( "DefaultEvent", "public:MainController.home" );
to
controller.setSetting( "DefaultEvent", "public:UtilController.invalidMethod" );
Because if the event is not found, the default one is invoked. Instead I would like a 404 to be shown.
It would be perfect if there was a way to say:
fires the invalidEventHandler method configured in Coldbox.cfc, without having to repeat it in my code.
I removed my “Router.cfc” inside the “public” module, I’m using “routes” inside the module configuration.
I don’t understand if this is okay, but no problem
.
Thank you very much again! 