Custom Event Routing/URL Mapping?

Hello,

I am very new to this framework, trying to evaluate whether it would
work for our current 12-year-old spaghetti-code extravaganza...

One hurdle to jump over is that our customer and their users are
extremely resistant to change. They are emphatic that all the existing
URLs continue working. Obviously switching to a front controller using
URL mapping/SES approach would cause every URL to change. Right now,
we use the old-school approach where each page has its own cfm that
acts as its own controller, essentially.

Besides forcing this unpopular change, has anyone else been able to
build, what I imagine would be, a custom URL mapping interceptor, or
are there any suggestions for how I might easily go about that (short
of setting up 10,000 redirects :))?

I'm imagining something that would dynamically change the front
controller at run-time, or be able to (auto-magically) recognize all
the cfm content pages as controllers, or else a totally custom
interceptor that will populate whatever event object/structure that
the SES interceptor is ultimately populating. I guess I'm basically
asking to use Coldbox without the front controller pattern...? :frowning:

Hope this makes sense and thanks for any insight,

Jen

Hi Jen,

Welcome to Coldbox! I had this same problem recently and was able to rectify by using the Coldbox invalid event setting. Once this is set you can evaluate where the user is trying to go and redirect accordingly.

Here is my invalidEvent method:

function invalidEvent(event){
var rc = event.getCollection();
var currentPageName = cgi.path_info;

var redirectPage = “”;
switch(currentPageName)
{
case ‘/overview.html’ : redirectPage = “overview”;break;
case ‘/foo.html’ : redirectPage = “partners/foo”;break;
case ‘/press.html’ : redirectPage = “press/index”;break;
}

if(redirectPage EQ “”)
event.setView(‘404’);
else
{
var pc = getpagecontext();
pc.getresponse().setStatus(301);
pc.getresponse().sendRedirect(’#prc.baseURL##redirectPage#’);

}
}

Hope this helps.

Nolan

That’s definitely one way. You can also use the missing template handler and when they hit the old and now missing front controllers you can easily know, redirect and such

Thanks for both of these suggestions. I'll give them a whirl!