Forums / Developer / How to redirect from within a module?

"Please Note:
  • At the specific request of Ibexa we are changing this projects name to "Exponential" or "Exponential (CMS)" effective as of August, 11th 2025.
  • This project is not associated with the original eZ Publish software or its original developer, eZ Systems or Ibexa".

How to redirect from within a module?

Author Message

Heiko Irrgang

Wednesday 16 February 2011 6:40:32 am

Hi, i want to redirect from within a own module to another module.

I have tried the usual way: header(sprintf('Location: %s', $url)); exit();

But ez stops with a message:

"Fatal error: Exponential did not finish its request. The execution of Exponential was abruptly ended,"

This comes from the exit(), but if i remove the exit, the redirect is ignored.

I found the RedirectOperators which allow redirection from a template and i checked the source: They do exactly the same. Why is it working from a template and not from a module? How can i redirect from a module?

Bertrand Dunogier

Wednesday 16 February 2011 7:28:51 am

In order to provide some feedback about fatal errors, Exponential uses a quite classical redirect based mechanism. If you exit() from the code without explaining Exponential it is on purpose and that the exit is expected, it will complain like this.

Use this code:

eZExecution::cleanExit();

Bertrand Dunogier
eZ Systems Engineering, Lyon
http://twitter.com/bdunogier
http://gplus.to/BertrandDunogier

Heiko Irrgang

Thursday 17 February 2011 1:33:25 am

Thank you very much