The basics are simple enough:
if (location.hash && (location.hash.substr(1,1) === "!")) {
location.replace(location.toString().replace('#!', "/"));
};
You just need to make sure that the new URLs work first.
That means:
- Updating the client side code to use pushState and friends (so you stop generating hashbang URIs)
- Updating the server side code so it can deliver each page of the site in the correct state without depending on the client side code (so that (a) any page can load quickly and efficiently and (b) JavaScript becomes a performance boosting bonus instead of a search engine hating dependancy)