I have several basic redirects on apache using mod_rewrite's RewriteRules. I want to do these redirections programatically, using Zend Framework. These redirections may include different domains. E.g.
RewriteRule ^/xmas(.*) http://mycdn.com/things/xmas$1 [P]
When redirecting with Apache, the url stays the same, e.g. on the address bar on the browser. I want to mimic this behaviour in ZF, but cannot find the way for other domains.
I can do it for in-site redirections via extending Zend_Controller_Router_Route
, extending the match()
method, and then returning an array with module, controller, action, etc. fields.
class My_Route extends Zend_Controller_Router_Route
{
// ...
public function match($path)
{
// ...
return
array(
'module' => 'default',
'controller' => 'mycontroller',
'action' => 'index',
);
}
}
But I haven't managed to make it work for redirecting to other domains, since it apparently only works for in-site routes (Haven´t found a way to specify domain or full url on the specs either).
I have tried another ways, like:
$r = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector');
$r->gotoUrl("http://otherdomain.com/some-stuff-to-redirect-to")->redirect();
and this does the redirection, but it totally changes the page making a whole new request.
How could I implement this in ZF? Using ZF1.