Rewrite only works when everything is on the same server, just the URLs/Hosts are different, as the example you gave.
As to what you want at the beginning of the thread, rewrite does not work. Maybe a reverse proxy to api.search.yahoo.com works, if the request without any change can be...