Better way to perform search/replace inside php upstream only