If your client wants to use URL-rewriting, then you have to make sure the server application supports it properly too, and many don't.
I suggest that a more robust solution is to use one of the many "web client" libraries which manage all the tedious stuff like cookies, headers, authentication and redirection for you.
My current favourite is HTTPUnit. It's described as a web site
test system, but it contains some powerful and easy to use classes for just this sort of thing. If's free, and it can be found at
http://httpunit.sourceforge.net/ .