URL rewriting bugfixes