Fixed link rewriting to avoid multiple "/" characters in front of paths