$(document).ready(function(){
var pieces = location.href.split('/');
if (pieces[3].indexOf('#!') !== 0) {
if (location.href.indexOf('#!') != -1) {
pieces = location.href.replace('#!','').split('/');
}
pieces[3] = '#!/'+pieces[3];
location.href = pieces.join('/');
}
});
Чтобы скрыть содержимое:
// I don't know you actually need this, since it may hide content
// in some cases when the redirect may not work, which might give
// the user a blank white page.
// Alternatively, you could use CSS as Ben notes, although you would
// only need display: none on the body tag.
$('body').ready(function(){$(this).hide();});
// Note, this is NOT in a handler.
var pieces = location.href.split('/');
if (pieces[3].indexOf('#!') !== 0) {
if (location.href.indexOf('#!') != -1) {
pieces = location.href.replace('#!','').split('/');
}
pieces[3] = '#!/'+pieces[3];
location.href = pieces.join('/');
}
Демо: http://jfcoder.com/test/redirect.html