ColdCourse Updated for Nicer URLs Regardless of Hosting
One of the biggest limiting factors of ColdCourse was that in order to get the full effect you needed to have a host that supported .htaccess files or have access to install an isapi filter on IIS. Not anymore though! Now you can create SES URLs regardless of your OS or host as long as you don’t mind BlogCFC style rewrites that look like /index.cfm/some/parameters. Here’s a rundown of how ColdCourse works:
You enter the URL into your browser such as http://localhost/mycontroller/myaction or http://localhost/index.cfm/mycontroller/myaction. ColdCourse takes over before your framework (fusebox, model-glue, mach-ii, coldbox or just about anything else) and tells your framework that the page that was really called was http://localhost/index.cfm?fuseaction=mycontroller.myaction. This is how ColdCourse had been all along when using .htaccess/isapi filters, but now you can call the http://localhost/index.cfm/mycontroller/myaction URL without any webserver setup.
All the same bells and whistles from before are still in there:
- Hooks into all major frameworks that use a single event/fuseaction variable with a single value.
- Ability to have unique URLs, so that http://localhost/index.cfm?fuseaction=mycontroller.myaction forwards the user to http://localhost/mycontroller/myaction for example.
- Ability to create new URL parameters programmatically rather than by editing a .htaccess file. For instance You might want http://localhost/user/AdamFortuna to be the same as http://localhost/index.cfm?fuseaction=user.about&username=AdamFortuna.
- Ability to have specifically named actions included automatically. For instance the URL http://localhost/home might be the same as http://localhost/home/index, or http://localhost/index.cfm?fuseaction=home.index. ColdCourse can make sure when someone types http://localhost/home/index it’ll redirect them to http://localhost/home
- All redirects are done using the “301 Moved Permanently” implementation which means search engines will pick up the new URLs with ease and not index multiple resources with the same content.
- You can drop it into an already existing application and see how it works! If you’ve been linking to resources with a prefix slash then ColdCourse will work right out.
Coldcourse is honestly a snap to use. There’s one setup file when you can basically forget about it until you have to create a custom course. If you’re in the market for SES URLs, give it a try!
If you enjoyed this post, please consider to leave a comment or subscribe to the feed and get future articles delivered to your feed reader.




Comments
Development setup IIS/2003:
localhost/appName/index.cfm
Error:
Model-Glue: There is no known event handler for “appName.index.cfm”
Ideas?
I’m not sure why .htaccess works but the same rules in the httpd.conf won’t but i thought it was worth a mention incase anyone else ran into this problem.
http://localhost/index.cfm is the “home” URL
setUniqueURLs = false
setBaseURL(”http://localhost/index.cfm”)
in my onrequeststart function in my controller I am setting myself value = “”
I don’t understand how/why index.cfm is an “event handler” as the “home” event handler is home which then does page.index. I have tried to change the value and add an event handler called index.cfm but I can’t seem to get Coldcourse to work. Do you have any suggestions as there is not a lot of MG:U examples with Coldcourse.
Thanks
Thanks
What server are you running it on? If you’re trying to routes in the
http://localhost/index.cfm/home/main
form, then you’ll need to remove all other routing with .htaccess/isapi filters, as that’s using base ColdFusion for the routing.
If you’re using those and have index.cfm in the BaseURL i think it will fail though, because apache/iis will convert htp://localhost/index.cfm into http://localhost/?event=index.cfm if I’m not mistaken, which will mess things up before it gets to coldcourse.
Shouldn’t worry about the onrequest start or anything within MG though. By the time it gets to MG all ColdCourse processing is done and the event should be set as a URL variable. I’d try making a onrequeststart function and dumping the URL scope to see what coldcourse is setting, then tweaking the CC settings to make it what you need.
I have a few things planned for CC including some more examples and documentation, but think that’ll be at least two weeks away at this point. I’ll make sure to add a MG example to the list though.
I am running on IIs. Dumping the URL scope gives me:
EVENT index.cfm.
Thanks Adam for a great tool!
Leave a comment