Forum Discussion

Bob_H__117248's avatar
Bob_H__117248
Icon for Nimbostratus rankNimbostratus
Sep 24, 2013

Using iRules for Redirects with strings

I'm looking for a way to redirect as follows:

 

http://mytraining.site.com?_cid=xxxxx redirecting to http://www.site.com/training/index.htm?_cid=xxxxx

 

The xxxxx is a variety of numbers. Right now my rule cuts off the ?_cid=xxxxx

 

Any help is greatly appreciated.

 

3 Replies

  • Something like this maybe:

    when HTTP_REQUEST {
        set query ""
        if { [URI::query [HTTP::uri] _cid] ne "" } {
            set query "?_cid=[URI::query [HTTP::uri] _cid]"
        }
        HTTP::redirect "http://www.site.com/training/index.htm${query}"
    }
    
  • Or maybe something like this example? This assumes that mytraining.site.com and www.site.com resolve to the same virtual server IP address.

    when HTTP_REQUEST {
    
       if {[HTTP::uri] contains "_cid=" and not ([HTTP::path] starts_with "/training/index.htm"}{
    
          HTTP::redirect "http://www.site.com/training/index.htm?_cid=[URI::query [HTTP::uri] _cid]"
       }
    }
    

    Aaron