Hello,
The filter is not necessary – as true
is its default value, you have to use the filter only if you want to disable the header.
I have tested this and it is working correctly for me – Rank Math SEO
is the value of the X-Redirect-By
header. Are you sure the redirection you are looking at is handled by Rank Math and not another plugin?
You can also try disabling other all plugins, to rule out possible plugin conflicts, and switch to a default theme like Twenty Nineteen to rule out a theme issue.
Also, please make sure to use the latest version of both Rank Math SEO and WordPress core.
Let us know how that helps.