How to make hashtag redirects in WordPress

One of my client asked me for redirects from URLs like http://example.org/#!contact. Some online content management systems use hashtag redirect for navigation, like Wix or Twitter. Actually Google recommends use them for AJAX navigation.

As you probably know, PHP does not get anything after hash tag, so it is not possible to parse request url and get hash using PHP. But JavaScript can.

Below you find my solution for WordPress redirects by hashtag #! :

(You should put this code in functions.php of your active theme):

Leave a Reply