An example of a complex two-way URL rewrite (TWURL) I have a complex TWURL that I need to perform. Any traffic to a particular URL needs to be redirected internally. Any traffic to a particular URL with "login" in the URL needs to be redirected externally
There may be times where you need to create a complex TWURL, such as you want a login to go to a remote site, but something other than a login goes to an internal site. This is a complex example of a TWURL rewrite.
Consider the case where : 1. Client reaches public portal (http://192.0.2.50) 2. The portal redirects to an internal server (http://192.0.2.1) 3. This internal server redirects to another server (http://example.com/) 4. This internal redirect should appear on the client as an external portal (http://192.0.2.50/login) -OR- 1. Whenever the client types in http://192.0.2.50/xxx (where xxx is not "login") then redirect to http://192.0.2.1 2. Whenever the client types in http://192.0.2.50/login/xxx then redirect to example.com
;;;the above is the important part. The above code will check if the response from the server anywhere includes example.com, if ;;;it does it converts it to /login, else if there is a reply from server being 192.0.2.1 it converts to 192.0.2.50.
define action change1 rewrite( url, "http://192.0.2.50/login/(.*)", "http://example.com/$(1)") transform P3 end
define action change2 rewrite( url, "http://192.0.2.50/(.*)", "http://192.0.2.1/$(1)") transform P3 end
;;;the above code takes care of client -> internal server mapping. Note both point to same transform
define action force_uncompressed delete( request.header.Accept-Encoding ) end