Skip to content

Instantly share code, notes, and snippets.

@vrypan
Created November 23, 2012 15:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vrypan/4136206 to your computer and use it in GitHub Desktop.
Save vrypan/4136206 to your computer and use it in GitHub Desktop.
smart redirects from 404 pages.
<script>
$.getJSON('/_/js/url_mapper.json', function(data) {
path = location.pathname.split("/") ;
if ( path[1] == "post" ){
id = path[2];
if ( data[id] ) {
$('#msg_en').html("The page you are looking has probably moved to \<a href=\"" + data[id] + "\"\>" + data[id] + "\</a\>.") ;
}
}
});
// See http://blog.vrypan.net/2012/11/23/dynamic-404-for-static-blogs/
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment