(PECL pecl_http >= 0.1.0)

http_redirectIssue HTTP redirect


bool http_redirect ([ string $url [, array $params [, bool $session = false [, int $status = 0 ]]]] )

Redirect to the given url.

The supplied url will be expanded with http_build_url(), the params array will be treated with http_build_str() and the session identification will be appended if session is true. The HTTP response code will be set according to status. You can use one of the redirect constants for convenience. Please see » RFC 2616 for which redirect response code to use in which situation. By default PHP will decide which response status fits best.

To be RFC compliant, "Redirecting to <a>URL</a>." will be displayed, if the client doesn't redirect immediately, and the request method was another one than HEAD.

A log entry will be written to the redirect log, if the INI-опцию http.log.redirect is set and the redirect attempt was successful.

Список параметров


the URL to redirect to


associative array of query parameters


whether to append session information


custom response status code

Возвращаемые значения

Возвращает FALSE или выходит при успешном завершении работы with the specified redirection status code. Смотрите INI-опцию http.force_exit для пояснения термина "выходит".


Пример #1 A http_redirect() example

("relpath", array("name" => "value"), trueHTTP_REDIRECT_PERM);

Результат выполнения данного примера:

HTTP/1.1 301 Moved Permanently
X-Powered-By: PHP/5.2.2
Content-Type: text/html

Redirecting to <a href=""></a>.

Смотрите также

  • класс HttpResponse если вы используете PHP 5.1.0 и выше


404 Not Found

404 Not Found


    Поддержать сайт на родительском проекте КГБ