Forum Discussion

ooby's avatar
ooby
Icon for Nimbostratus rankNimbostratus
Mar 31, 2020
Solved

65,000 character limit in irule and URI redirects

Hi all,

I've been asked to do something and the way I thought I could do it isn't working (and probably isn't the best way to go about it)

We have 2 domains (domain1.net.com an domain2.org.info).

Domain1.net.com is closing down and we want to use 301 redirects to domain2.org.info. I've been asked to redirect over 1000 unique URI's on domain1.net.com to unique URI's on domain2.org.info.

I thought I could write an irule with an if statement listing out all the unique URI's but when I uploaded the irule to the F5 I received an error that the irule character limit didn't allow it.

Is there a way I can easily do this?

 

Example of my irule is below

 

 when HTTP_REQUEST {

 

  if { [HTTP::uri] contains "<UNIQUE/STRING>"} {

    HTTP::redirect "https:/domain2.org.info/UNIQUE/URI/GOES/HERE/"

  }

  elseif { [HTTP::uri] contains "<UNIQUE/STRING>"} {

    HTTP::redirect "https:/domain2.org.info/UNIQUE/URI/GOES/HERE/"

  }

  elseif { [HTTP::uri] contains "<UNIQUE/STRING>"} {

    HTTP::redirect "https:/domain2.org.info/UNIQUE/URI/GOES/HERE/"

  }

  elseif { [HTTP::uri] contains "<UNIQUE/STRING>"} {

    HTTP::redirect "https:/domain2.org.info/UNIQUE/URI/GOES/HERE/"

  }

  elseif { [HTTP::uri] contains "<UNIQUE/STRING>"} {

    HTTP::redirect "https:/domain2.org.info/UNIQUE/URI/GOES/HERE/"

  }

  elseif { [HTTP::uri] contains "<UNIQUE/STRING>"} {

    HTTP::redirect "https:/domain2.org.info/UNIQUE/URI/GOES/HERE/"

  }

   elseif { [HTTP::uri]..............

 

and so on. As mentioned, there are over 1000 unique URI's on domain1 that they want to redirect to unique URI's on domain2

 

Happy for any advice.

 

Thanks

5 Replies

  • ooby's avatar
    ooby
    Icon for Nimbostratus rankNimbostratus

    Thanks S Blakely,

    I've never done that before but will give it a shot - thanks!

  • ooby's avatar
    ooby
    Icon for Nimbostratus rankNimbostratus

    An update to this.

    I've created the data group. The information looks like this

     

    "unique/uri/is/here" := "https://www.domain2.net.org/unique/uri/goes/here",

     

    That goes on for about 1000 rows. I saved it as a CSV file in notepad.

    I uploaded that file to the F5 as per https://support.f5.com/csp/article/K73862425. I created the Data Group File List as a name like DGNAME.TXT, chose String as the File Contents and the Key Seperartor as :=. The file imported ok

     

    I then created the External Data Group and named it NAMEHERE and chose the DGNAME.TXT file I uploaded

     

    The problem I have now is getting the iRule to work. I've looked at a few options but none seem to work. This is my latest iRule

     

     

    when HTTP_REQUEST {

       if { [class match [HTTP::uri] contains "NAMEHERE"] } {

      HTTP::respond 301 location "https://[HTTP::host][class lookup NAMEHERE]"

       }

     }

     

    I'm unable to get anything to happen and the page times out.

     

    Any ideas would be appreciated

     

    Thanks

    • You need

      when HTTP_REQUEST {
         if { [class match [HTTP::uri] contains NAMEHERE] } {
           HTTP::respond 301 location "[class match -value [HTTP::uri] contains NAMEHERE]"
         }
      }
  • ooby's avatar
    ooby
    Icon for Nimbostratus rankNimbostratus

    Thanks so much - that is working.

    I did have to go through and remove the white space in my URI's (they had 'unique/uri is here/and here/) and replace the white space with %

    Again - appreciate your help