properly replace all rewritten links 

I'm not sure why this worked earler but the Array need to be flattened apparently