Forum Discussion

Joe_105988's avatar
Joe_105988
Icon for Nimbostratus rankNimbostratus
Mar 03, 2008

Question on how to create a HTTP redirect rule

I am new to creating iRules and need to create one that redirects either of 2 urls (for both http or https) to one url (https).

 

 

 

Any help would be appreciated.

 

 

Thanks!

4 Replies

  • Hi,

     

     

    You should have a look at all the previous posts.

     

     

    Just on the main page of this forum you have this question which is asked several times.

     

     

    You should be able to find what you're looking

     

     

    example:

     

     

    Click here

     

    Click here

     

    Click here

     

  • I do not see an instance where there are multiple URLs that need to be directed to 1. Can I use multiple 'When' statements in the same iRule? If so, I can see how this can be done.
  • You can use multiple when yes.

     

     

    Otherwise to match multiple URIs you can use something like switch.

     

     

    An extract from one of the link i sent you

     

     

    when HTTP_REQUEST {

     

    switch -glob [HTTP::URI] {

     

    "/" { HTTP::redirect "https://[HTTP::host]/PortalWAR/appmanager/portal/home" }

     

    "/blah/blah*" { HTTP::redirect "https://[HTTP::host]/[HTTP::uri]" }

     

    "*blah" { HTTP::redirect "https://[HTTP::host]/[HTTP::uri]" }

     

    "blah*" { HTTP::redirect "https://[HTTP::host]/[HTTP::uri]" }

     

    "b?ah" { HTTP::redirect "https://[HTTP::host]/[HTTP::uri]" }

     

    }

     

    }

     

    }

     

     

    Here all those URI will be redirected to something else.

     

     

    Here you have an example with some regexp.
  • If you cut and paste the example above, then remove the extra "}" brace at the end. That should allow the code to run.

     

     

     

    -CB