-
-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ability to specify response code on controller plugin redirect #4
Comments
There is an open todo in the class of the redirect plugin: In the meantime you can use this workaround in any controller action: public function indexAction()
{
$response = $this->getResponse();
$response->getHeaders()->addHeaderLine(
'Location',
'https://github.com'
);
$response->setStatusCode(301);
return $response;
} Originally posted by @froschdesign at zendframework/zend-mvc#313 (comment) |
… toUrl() Signed-off-by: Abdul Malik Ikhsan <[email protected]>
… toUrl() Signed-off-by: Abdul Malik Ikhsan <[email protected]>
Signed-off-by: Abdul Malik Ikhsan <[email protected]>
I created PR #61 for it |
Would it be a solution to pass the desired status code as an optional parameter to the |
As mentioned on slack ( https://laminas.slack.com/archives/C4R13GTRD/p1670227522366209 ) return $this
->redirect()
->toUrl('https://github.com')
->setStatusCode(301); |
improves Redirect plugin docs showing how to set status code. #4
I have changed my routing setup on a production app, and I would like to provide search engines with the information that a new URL format is being used. For this I would like to use code 301 (Permanently Moved) instead of 302 (Found).
Code to reproduce the issue
In a controller action:
Expected results
I should be able to specify a statusCode of choosing
Actual results
The browser receives a 302 response code always.
Thanks for all your support!
Originally posted by @jroedel at zendframework/zend-mvc#313
The text was updated successfully, but these errors were encountered: