가능한 중복 :
return a specific http status code with phpPHP에서 http statuscodes를 반환하는 방법은 무엇입니까?
어떻게 프로그래밍 PHP로 특정 HTTP statuscodes을 보낼 수 있습니까? 거기에 어떤 방법이나 수업이 있습니까? header()
기능에
가능한 중복 :
return a specific http status code with phpPHP에서 http statuscodes를 반환하는 방법은 무엇입니까?
어떻게 프로그래밍 PHP로 특정 HTTP statuscodes을 보낼 수 있습니까? 거기에 어떤 방법이나 수업이 있습니까? header()
기능에
header()
기능이 필요합니다.
void header (string $string [, bool $replace = true [, int $http_response_code ]])
찾는 것이 바로 응답 출력 렌더링 스크립트 제 <?php
태그 후.
봐 :
header('HTTP/1.0 404 Not Found');
넣어 스크립트의 모든 출력 전에.
보내기 참조해야 클라이언트에 다른 것을 보내 header()
전에. 가능한 상태 헤더는 다음과 같습니다.
header('HTTP/1.1 200 OK');
// Page was not found:
header('HTTP/1.1 404 Not Found');
// Access forbidden:
header('HTTP/1.1 403 Forbidden');
// The page moved permanently should be used for
// all redrictions, because search engines know
// what's going on and can easily update their urls.
header('HTTP/1.1 301 Moved Permanently');
// Server error
header('HTTP/1.1 500 Internal Server Error');
// header for telling the browser that the content
// did not get changed
header('HTTP/1.1 304 Not Modified');
정교한 답변은 http://stackoverflow.com/a/6164319/1395993을 참조하십시오. –