Simplify redirect, redirectURL

1) redirect() and redirectURL() is similar functions, so let's "merge" them.
2) redirect() should better call location() and not deal with document.location directly.

I believe both these fixes are good because it helps to keep similar code in one place.