Note that there are some explanatory texts on larger screens.

plurals
  1. POZF2 redirect() not working while header location does
    text
    copied!<p>I have a controller with an index action in which I use a redirect to route:</p> <pre class="lang-php prettyprint-override"><code>$this-&gt;redirect()-&gt;toRoute('dummy-route')-&gt;setStatusCode('301'); </code></pre> <p>This works on my local development machine, but as soon as I deploy it to staging the redirect is not working anymore. I have set a header('Location: ') just to see if redirects are working and it does work as expected.</p> <p>What can be making the zf2 redirect to not work on the second machine?</p> <p>@noobie-php Yeah sure, here is the code:</p> <pre><code>public function indexAction() { $this-&gt;redirect()-&gt;toRoute('base-calculator')-&gt;setStatusCode('301'); exit; } </code></pre> <p>And routes:</p> <pre><code>'application' =&gt; array( 'type' =&gt; 'Literal', 'options' =&gt; array( 'route' =&gt; '/application', 'defaults' =&gt; array( '__NAMESPACE__' =&gt; 'Application\Controller', 'controller' =&gt; 'Index', 'action' =&gt; 'index', ), ), 'may_terminate' =&gt; true, 'child_routes' =&gt; array( 'default' =&gt; array( 'type' =&gt; 'Segment', 'options' =&gt; array( 'route' =&gt; '/[:controller[/:action]]', 'constraints' =&gt; array( 'controller' =&gt; '[a-zA-Z][a-zA-Z0-9_-]*', 'action' =&gt; '[a-zA-Z][a-zA-Z0-9_-]*', ), 'defaults' =&gt; array( ), ), ), ), ), 'base-calculator' =&gt; array( 'type' =&gt; 'Segment', 'options' =&gt; array( 'route' =&gt; '/calculate[/:criteriaFirst][/:criteriaSecond]', 'constraints' =&gt; array( 'action' =&gt; '[a-zA-Z][a-zA-Z0-9_-]*', 'id' =&gt; '[0-9]+', ), 'defaults' =&gt; array( 'controller' =&gt; 'Application\Controller\Index', 'action' =&gt; 'calculator', ), ), ) </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload