fixes #5773 - redirect to referrer URL that includes page and search

Another BZ was filed against the templates page (which is a place where it's annoyed me previously), so I think this is the way to go.