For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Forum Discussion

ebowers_25830's avatar
ebowers_25830
Icon for Nimbostratus rankNimbostratus
Nov 22, 2013

Irule for Redirecting 15 paths to new url

Hello

I have been asked to redirect an url that has 15 differant paths to a new url with a modified path

Here is and expample www.xyz.com/2013/11/07/enterprise-risk-management-getting-the-tone-right/ to www.newhome.com/knowledge/blog/enterprise-risk-management-getting-the-tone-right.html

            The /2013/ is the same on all request  but the 11/07  could be differant
                            After the 11/07 its a match per url

                                                                                                                            The www.xyz.com is a vip and pool combo but the www.newhome.com is external to us.

thank you for your help in advance....

6 Replies

  • Can you provide more detail as to what you want to acheive. If you are running v11.4, you can make use of Rewrite profile to rewrite URIs. Based on what you have mentioned you might have to use iRules to accomplish it. That is, rewrite URL and URI on HTTP_REQUEST and rewrite the URLs and URIs back on HTTP_RESPONSE.
  • We are using V 11.3 Looking ofr an Irule to do redirect. I have done some simple one for one redirect but not sure of format for something like this www.genreperspective.com/2013/11/07/enterprise-risk-management-getting-the-tone-right/www.genre.com/knowledge/blog/enterprise-risk-management-getting-the-tone-right.html www.genreperspective.com/2013/11/04/individual-critical-illness-application-development/www.genre.com/knowledge/blog/individual-critical-illness-application-development.html www.genreperspective.com/2013/10/30/possible-environmental-cause-of-autism-discovered/www.genre.com/knowledge/blog/230537781.html www.genreperspective.com/2013/10/28/how-to-find-paths-to-growth/www.genre.com/knowledge/blog/how-to-find-paths-to-growth.html
  • sorry for format issue, going from www.genreperspective,com to www.genre.com / 2013 is common incomming request
  • Something like this:

    when HTTP_REQUEST {
        set uri_end [getfield [HTTP::uri] "/" 5]
        set uri_start "http://www.xyz.com/abc123/this-is-the-new-URL/"
        HTTP::redirect "$uri_start$uri_end"
    }
    
  • You have an errant closing square bracket after your conditional if statement and the "genreperspective" string would be in the [HTTP::host] value, not the [HTTP::path]. Otherwise, if you can guarantee that the "/2013/x/x" URI pattern always exists before the URI portion that you want to capture, then you can also do this:

    when HTTP_REQUEST {
        if { [string tolower [HTTP::host]] equals "www.genreperspective.com" } {
            set newuri [lindex [split [HTTP::uri] "/"] 4]
            HTTP::redirect "http://www.genre.com/knowledge/blog/${newuri}.html" 
        }
    }
    

    This is simply splitting the incoming URI into a list and plucking out the 5th element (similar to Pete's getfield command).