Copy plugin changes for url rewriting

These got so far from master, I hand-picked them back onto a new branch.