Forum Discussion
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
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.
- Simon_BlakelyEmployee
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.
- oobyNimbostratus
Thanks S Blakely,
I've never done that before but will give it a shot - thanks!
- oobyNimbostratus
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
- Simon_BlakelyEmployee
You need
when HTTP_REQUEST { if { [class match [HTTP::uri] contains NAMEHERE] } { HTTP::respond 301 location "[class match -value [HTTP::uri] contains NAMEHERE]" } }
- oobyNimbostratus
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
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com