Proposal to fix generated URLs when SCRIPT_NAME is set.

Please see comments on issue 1122 for discussion.