smarter redirection based on pathname, hash and history status