Forum Discussion

PacketHead_4009's avatar
PacketHead_4009
Icon for Nimbostratus rankNimbostratus
Oct 18, 2011

Redirect iRule to Dynamic URL?

Hello All,

 

 

Have a quick question. I want to setup a standard "contains" iRule redirect but it needs to be able to work with dynamic URLs. What I mean by dynamic is that there is a small part of the incoming URL that is different for each session. In the URL below you can see were the =xxxx is usually a 4 digit number which is the customer code. Is this possible?

 

 

 

Redirect incoming requests that contain:

 

 

 

http://mysite.com/vbapp/customer=xxxx/goto/dev/

 

 

 

to

 

 

 

http://hosted99.com/vbapp/customer=default/login.aspx

 

 

 

I can get the first part of the iRule to work right because I can just state that anything containing "mysite/vbapp" will be directed regardless of the "xxxx" value. The only issue is that when it is redirected I can't get it to keep the original customer number in place.

 

 

 

Is this possible? Hopefully I explained it clearly.

 

 

 

Thanks!

 

 

 

James

 

 

 

 

 

 

 

  • Hi PacketHead,

    Sure you can do something like that. You can match on however much of the HTTP::uri you need to to insure it is a qualified match and then perform a redirect.

    Something like this:

    
    when HTTP_REQUEST {
    if { [string tolower [HTTP::uri]] contains "/vbapp/customer=" } {
    HTTP::redirect "http://hosted99.com[HTTP::uri]"
    }
    }
    

    This is not the only method that you have at your disposal. There are many ways to perform the same type of thing if you want an alternate solution.

    Hope this helps.
  • The only issue is that when it is redirected I can't get it to keep the original customer number in place.

     

     

    Redirect incoming requests that contain:

     

     

    http://mysite.com/vbapp/customer=xxxx/goto/dev/

     

    to

     

    http://hosted99.com/vbapp/customer=default/login.aspx

     

     

    i don't see xxxx in redirect link. how can you keep xxxx after redirection??
  • Posted By Michael Yates on 10/18/2011 02:43 PM

    Hi PacketHead,

    Sure you can do something like that. You can match on however much of the HTTP::uri you need to to insure it is a qualified match and then perform a redirect.

    Something like this:

     when HTTP_REQUEST { if { [string tolower [HTTP::uri]] contains "/vbapp/customer=" } { HTTP::redirect "http://hosted99.com[HTTP::uri]" } } 

    This is not the only method that you have at your disposal. There are many ways to perform the same type of thing if you want an alternate solution.

    Hope this helps.

    Hello Michael,

    Thanks for the reply. So given the script you provided the redirect URL will be as follows:

    http://hosted99.com/vbapp/customer=8745/login.aspx

    The script you provided will automatically take the remaining part of the incoming URL (/vbapp/customer=8745/login.aspx) and add it to the end of the new redirect URL http://hosted99.com making it a complete URL of http://hosted99.com/vbapp/cusotmer=8745/login.aspx?

    Hopefully I am understanding correctly.

    Thanks again,

    James

  • Hi PacketHead,

     

     

    Yes. You have it right.

     

     

    If you have any problems with it or need an alternate solution just let us know.