Backport of PR #836 from master to 2.x branch.

This fixes the relative URI issue for 2.x users.