Have a look at the mod_proxy documentation, I think the ProxyPassMatch directive is of interest.
ProxyPassMatch