cancel
Showing results for 
Search instead for 
Did you mean: 
Login & Join the DevCentral Connects Group to watch the Recorded LiveStream (May 12) on Basic iControl Security - show notes included.

iRule for GET and POST to redirect to different URLs

Sulabh_Srivasta
Altostratus
Altostratus

Hi All,

 

I need help in setting up iRule to redirect to separate URLs for GET and POST request. I have iRule configured for GET request and working but not able to sue for POST request.

 

GET: 

https://www.abc.com/AA/BB ----> https://Node_X:10004/AA/BB

 

POST:

https://www.abc.com/AA/BB ----> https://Node_P:10008/AA/YY/ZZ

 

Any help will be greatly appreciated.

Thank you.

1 REPLY 1

SanjayP
MVP
MVP

It appears, for POST request you want uri rewrite, where first uri path would be same, trimming anything after it and adding some other static URI path but not from the request itself? Also, this doesn't appear to be redirect but sending to pool (or node) on the same LTM? Please note, HTTP POST method doesn't follow a redirect.

 

If yes for all above, you can try the below code.

 

when HTTP_REQUEST { switch -glob [string tolower [HTTP::uri]] { "/aa*" { if { [HTTP::method] eq "POST" } { set first_uri [lindex [split [HTTP::uri] "/"] 1] set new_uri /$first_uri/YY/ZZ HTTP::uri $new_uri pool p_10008 } else { pool x_10004 } } default { return } } }