Fix regression on `assert_redirected_to`, 4-1-stable

backport #15084 to fix regression added on 4.1.0

review @pixeltrix