HTTP 303은 사용자 지정 리디렉션 헤더이며 오류가 아니므로 HTTP POST 후에 사용해야합니다. 기존 URL을 보존하는 것이 원하는 경우 (서재용 등) HTTP 301 - Moved Permanently 헤더를 사용하는 것이 좋습니다.
여러 가지 방법이 모두 의 다른 자원 HTTP 서버 및 응용 프로그램 수준으로 모든 HTTP 요청을 리디렉션하는 존재가있다. 나는 nginx/apache 레벨을 선호한다. Nginx에 대한 예 :
응용 프로그램 수준에서
HTTP/1.1 303 See Other
Server: nginx/1.X.0
Date: Tue, 07 Oct 2014 20:47:29 GMT
Content-Type: text/html; charset=UTF-8
Content-Length: 168
Connection: keep-alive
Location: http://www.example.com/category/prodct123
, 당신은 쉽게 내부 요청을 리디렉션 할 수 있습니다 :이 유사한 반응을 생산할 예정이다 HTTP 서버의 구성을 다시로드 한 후 이전 /category/product123.html
URL을 호출 이제
server {
# ...
location ~ "^/category/([a-zA-Z0-9]+).html" {
# Example: http://www.example.com/category/product123.html
# The $1 will be product123
return 303 http://www.example.com/category/$1;
}
# ...
}
, 유효한 Response 개체로 반환하는 컨트롤러 작업 :
public function anyControllerAction()
{
$response = $this->getResponse();
$response->getHeaders()->addHeaderLine('Location', 'http://www.example.com/category/prodct123');
$response->setStatusCode(303);
return $response;
}
희망이 있습니다.