fix behavior of trailing slash redirection when a query string is involved (closes #23112)

--HG--
branch : 2.7
use getentropy when available (backport of 75ede5bec8db) (closes #23115)

--HG--
branch : 2.7