Remove reload parameter during history handling

The regex is kind of complex here, so please take a close look.
Let's capture the remaining query in the regex and remove the trailing "?" if possible.