Rewrite redirect middleware to allow full url redirect and use caching for speed