title: ZF2 - How to re-direct to External URL
body: <p>I am using ZF2 and I am wondering how to re-direct to an external URL.</p>
  
  <p>This is what I have tried:</p>
  
  <pre><code>    $this-&gt;redirect()-&gt;toUrl('http://www.example.com' ,
          [
              'access_code'         =&gt; '12345'
          ]
      );
  </code></pre>
  
  <p>Unfortunately it does not work.</p>
  
  <p>The other thought was to simple use something like:</p>
  
  <pre><code>header('Location: http://www.example.com/12345');
  </code></pre>
  
  <p>EDIT:</p>
  
  <p>This is being done from my controller, here is the controller code:</p>
  
  <p>
  
  <pre><code>use Application\Library\Http\GetHttpInterface;
  use Zend\Mvc\Controller\AbstractActionController;
  use Zend\View\Model\ViewModel;
  class GamesController extends AbstractActionController
  {
  
      public function __construct(
          //factories
      ) {
          //objects
      }
  
      public function redirectAction()
      {
  
          $this-&gt;redirect()-&gt;toUrl("http://www.example.com");
  
  
         echo "here";
  
      }
  
  }
  </code></pre>