@arnova: An alternative would be splitting on /, encoding piece by piece and then reassembling.