cancel
Showing results for 
Search instead for 
Did you mean: 

65,000 character limit in irule and URI redirects

ooby
Nimbostratus
Nimbostratus

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

1 ACCEPTED SOLUTION

Simon_Blakely
F5 Employee
F5 Employee

Use an external datagroup to store your translations,

 

K73862425: Creating external data groups

 

Your irule looks up the key, and redirects to the value indexed by the key.

 

View solution in original post

5 REPLIES 5

Simon_Blakely
F5 Employee
F5 Employee

Use an external datagroup to store your translations,

 

K73862425: Creating external data groups

 

Your irule looks up the key, and redirects to the value indexed by the key.

 

ooby
Nimbostratus
Nimbostratus

Thanks S Blakely,

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

ooby
Nimbostratus
Nimbostratus

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
Nimbostratus
Nimbostratus

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