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

Mary_Paseli_638's avatar
Mary_Paseli_638
Icon for Nimbostratus rankNimbostratus
Dec 13, 2016

Best way to redirect aprox. 1000 urls

We are using F5 10050 version 11.6.1 Build 0.0.317

 

I need to redirect about 1000 urls using an iRule. I have never done this but after reading some data, I see that we can do it via a Data Group List. How would I go about this by setting up a text file with all the redirects.

 

An example of one of the urls that I need to redirect:

 

From: http://publications.mcgill.ca/mcgillnews/2015/10/09/the-myths-around-not-criminally-responsible/ To: http://mcgillnews.mcgill.ca/s/1762/news/interior.aspx?sid=1762&gid=2&pgid=572

 

Greatly appreciate any help! Thank you Mary Paseli

 

2 Replies

  • You can also use HTTP Local Policies which are basically irules. I hope you can use some wildcards in the URL's to limit the . I am not sure you can have 1000 rules in a HTTP policy for URL redirection. With such a large you might need to consider data-groups and or referencing an external file with an irule.

     

  • Hi Mary,

    you may try the iRule and external data-group below (or at least take a look at it :)...

    when HTTP_REQUEST {
        if { [set location [class match -value [string tolower "[HTTP::host][HTTP::uri]"] starts_with DG_MyRedirects]] ne "" } then {
            HTTP::redirect $location    
        }
    }
    

    External data-group structure:

    "input_url" := "target_url",
    "publications.mcgill.ca/mcgillnews/2015/10/09/the-myths-around-not-criminally-responsible" := "http://mcgillnews.mcgill.ca/s/1762/news/interior.aspx?sid=1762&gid=2&pgid=572",
    "publications.mcgill.ca/somepath" := "http://mcgillnews.mcgill.ca/page.aspx?path=somepath",
    "publications.mcgill.ca/somepath/somepath" := "http://mcgillnews.mcgill.ca/page.aspx?path=somepath%2Fsomepath",
    

    Note: The ordering of the data-group does not matter, the

    [class]
    command will always pick the best-matching entry and use the "target_url" data for the redirect. Also keep in mind that the outlined iRule uses a
    starts_with
    operator, so that you can redirect every request underneath a given URL structure to the new URL.

    For more information on external data-groups take a look to the

    [class]
    command wiki site.

    https://devcentral.f5.com/wiki/iRules.class.ashx

    Cheers, Kai