Forum Discussion

Chris_123510's avatar
Chris_123510
Icon for Nimbostratus rankNimbostratus
Jan 09, 2015

URL Redirect Question

I have to do a redirect and append the uri to the URL that I am redirecting to. Below is what I am looking to do.

 

Clients will come into this URL: a.bcde.com/10 Random Character Set

 

I will need to redirect to the following URL: f.ghij.com/site/now/10 Random Character Set (same from original Client incoming URL)

 

Any help on this is greatly appreciated!

 

Chris

 

3 Replies

  • You could use an iRule like this to do the redirect. If it's just basic, then this should do (if you always want to redirect, you could even take out the

    if
    statement). Do you need to do anychecking on the 10 digit URI string?

    when HTTP_REQUEST {
        if { [string tolower [HTTP::host]] equals "a.bcde.com" } {
            HTTP::redirect "http://f.ghij.com/site/now[HTTP::uri]"
        }
    }
    
  • Michael,

     

    Thank you for the assistance on this! We just had the chance to test it and it worked just like we wanted it to. I did make a slight change, I took the / out from behind "now" in the redirect, as the [HTTP::uri] will bring the trailing / from the original URL.

     

    Chris

     

    • Michael_Jenkins's avatar
      Michael_Jenkins
      Icon for Cirrostratus rankCirrostratus
      Oh yea. Forgot that the HTTP::uri always has the initial "/" on it. I've updated my original answer to reflect that. Good catch! If you don't mind, please mark the answer as the solution so others can see that it's been solved. Thanks!