I have problems using _redirect() on server provided by home.pl (hosting company in Poland). They use their custom http server and emulate mod_rewrite for it. Things works perfectly until I use mod_rewrite to redirect all requests to bootstrap file, and then try to redirect to different path using _redirect() - default behavior with ZendFramework.
When server receives relative redirect request from php, it resolves its target (being still the same bootstrap index.php file because of rewriting) and send internally request to this file again without changing the path in the uri - the server doesn't send header "Location" to the browser.
The unwanted result of this action is unchanged path in URI, ie. when I redirect from /test/of/redirect/ to /test using header "Location: /test/", after redirection the script still gets the old path "/test/of/redirect/".
When I use redirection using absolute URI, redirection works right.
To make things work i did a dirty hack in metod _redirect() of Zend_Controller_Action (0.9.1):
if ($prependBase && !preg_match('|^[a-z]+: $request = $this->getRequest();
if ($request instanceof Zend_Controller_Request_Http) {
$base = $request->getBaseUrl();
if (('/' != substr($base, -1)) && ('/' != substr($url, 0, 1))) {
$url = $base . '/' . $url;
} else {
$url = $base . $url;
}
# THE HACK:
$url = 'http: }
}
I asked my hosting company about that and I received an answer:
Please consider that server behaviour is correct, that is, location is passed in the right way.
If you want to change location (URI), please use absolute redirections (301, 302)
Considering RFC 2616 mentioned above, they are perfectly right.
Is there a better way than the dirty hack to make absolute redirections using _redirect()?
Will this issue be considered in future versions od ZendFramework?
Assign to Matthew.