I am working on cms page restriction for specific customer group.I am using controller_action_predispatch event observer to check whether the current page is set for restriction and the current customer's group is allowed to visit the page. If customer's group is not allowed I am redirecting them to a error page. The real problem is, they should be allowed to visit the error page on observer redirection, in case of direct url access they shouldn't be allowed to visit that error page. I was trying to set post parameter on observer redirection, so that page could know they are coming from observer redirection. On direct URL access of that page, parameter won't be set. Then I could redirect them to home page. But I couldn't be able to find a solution to set a post param in observer redirection. Also tried using session variable and session cookie but not working well. Is there any solution for this?

Sorry for the long description. Thanks in advance.

1 Answer 1


If restricted the Please can you try this $this->forward->forward('noroute');

Class namespace: Magento\Framework\Controller\Result\Forward


  • Let me check your suggestion and I will get back to you... May 22, 2022 at 7:04
  • Thanks for the respose. But I want to redirect customer to a specific error page that I created. I made my block cacheable false and using session variables It's working fine now. May 24, 2022 at 7:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.