core: URL rewriting - phase 1