I am trying to redirect users to a page on entity view. I am using RedirectResponse in hook_entity_view. But it is not redirecting to the desired page.
This is how I implemented this. After fetching my redirect url, I have passed it to RedirectResponse.
return new RedirectResponse($redirect_url);