apply_filters( ‘wp_redirect_status’, int $status, string $location )

Filters the redirect HTTP response status code to use.

Parameters

$statusint
The HTTP response status code to use.
$locationstring
The path or URL to redirect to.

Source

$status = apply_filters( 'wp_redirect_status', $status, $location );

Changelog

VersionDescription
2.3.0Introduced.

User Contributed Notes

  1. Skip to note 2 content

    Example Migrated from Codex:

    Convert HTTP/1.1-only status codes to 1.0 equivalents when using HTTP/1.0

    add_filter( 'wp_redirect_status', 'http_status_version_downgrade');
    
    function http_status_version_downgrade($status, $location) {
    
        static $HTTP11_to_10 = array(
            203 => 200,
            303 => 302, 307 => 302, /* 305 => No 1.0 equivalent ,*/
        );
    
        if( $_SERVER['SERVER_PROTOCOL'] == 'HTTP/1.0' 
            && isset($HTTP11_to_10[$status]) ) 
        {
            return $HTTP11_to_10[$status];
        }
    
        return $status;
    }

You must log in before being able to contribute a note or feedback.