fix rewrite base detection for root of alias

Bc break: no
Fixes #536

@fabpot please also merge 2.2 in to master then.