Rewrite rewriteUrls with preg_replace_callback

preg_replace_callback with anonymous function can be used when php>5.3.0
For earlier versions, I left the old code.