Application Delivery (ADX)

URL rewrite: How to rewrite client URLs

by pmorrissey on ‎06-23-2009 05:00 AM - edited on ‎10-30-2013 05:39 PM by bcm1 (1,033 Views)

Summary

Sometimes it is necessary to rewrite the URL in incoming client requests. e.g.,The web server directory structure might change and it might be important to keep existing client bookmarks alive. We will show how to insert a specified string at the beginning of the URL coming from the client.

 

For example, if the incoming url is "/myurl.html", we want to modify it such that it becomes "/mystring/myurl.html".

Specifics

URL Rewrite is supported for incoming traffic in clear-text HTTP or SSL (in SSL Terminate and SSL Proxy mode). It is also compatible with all other traffic management manipulation operations, including cookie-switching, client-ip insertion etc.

Configuration

csw-rule "r10" url prefix "/"
!

csw-policy "p10"

  match "r10" forward 10

  match "r10" rewrite request-insert "mystring/"

!

server real rs18 10.1.1.18

  port http

  port http url "HEAD /"

  port http group-id  10 10

!

server real rs19 10.1.1.19

  port http

  port http url "HEAD /"

  port http group-id  10 10

!

server virtual vip1 10.45.4.240

  port http

port http csw-policy "p10"

  port http csw

  port http keep-alive

  bind http rs18 http rs19 http

Note that the match string is "/", and the inserted string is the new URL. Since any new URL starts with "/", including blank URL's, therefore, it will be matched in all conditions, and thus, we do not need any default rule!!!

 

Please ensure the "keep-alive" setting for the virtual server port (port http keep-alive) is part of the configuration. It is required!

Tips / Caveats

Further Reading

 

Check out Reference: Using offset command to find out how to specify where in the request to make necessary changes

Contributors