We're using Zend Framework 2 and use toRoute
within our controllers to redirect to various locations, for example $this->redirect()->toRoute('home');
.
Is there anyway to have this redirect to https instead of http using this method or an alternative method?
Thank you!
In order to use
https
in your route you need to use theZend\Mvc\Router\Http\Scheme
router. Specifying the configuration for such route is not very different from the other routes. You need to specify the route type asScheme
and add an option'scheme' => 'https'
in your router configuration in module.config.php.Here is an example:
If you have the route
routename
configured like above, this:$this->redirect()->toRoute('routename');
will work.See this for reference to the ZF2's manual.
Hope this helps :)
Stoyan