Set Cache-Control header for 301 redirects

You first problem is that $status is not coming from anywhere. In a filter you need to accept arguments in your callback function. If the number of arguments you’re accepting is greater than 1 then you also need to specify that number as the 4th argument to add_filter().

You also need to return that value or the modified value. In this case if you don’t do that then you’re removing the status code from all redirects.

With these issues corrected your code will look like this:

function cache_control_handle_redirects( $status, $location ) {
    if ( $status == 301 || $status == 308 ) {
        header ( "Cache-Control: no-cache, no-store, must-revalidate" );
    }

    return $status;
}
add_filter( 'wp_redirect_status', 'cache_control_handle_redirects', 10, 2 );

That should do what you want.

There is a conceptual issue with this, in that filters should probably only be used for modifying values and not performing actions like this. That said, I don’t see any alternatives other than plugging the wp_redirect() function to incorporate this functionality and it should work regardless.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)