Optimized url_rewrite script.