Skip to content

Instantly share code, notes, and snippets.

@stevewithington
Last active December 14, 2023 10:04
Show Gist options
  • Save stevewithington/637e62d7db7b8943cf6b67153231ed0e to your computer and use it in GitHub Desktop.
Save stevewithington/637e62d7db7b8943cf6b67153231ed0e to your computer and use it in GitHub Desktop.
Mura CMS: 404 Redirect Example
<cfscript>
public any function onSite404(m) {
if (m.event('currentFilenameAdjusted') == 'some/bad-url') {
// If you want to preserve the requested URL ...
// var cb = m.getBean('content').loadBy(filename='some/good-url');
// m.setContentBean(cb);
// If you want to redirect to the new URL ...
location(url=arguments.m.createHREF(filename='some/good-url'), addtoken=false);
}
}
</cfscript>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment