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