I will be migrating a .NET environment with approximately 300 parent web directories. We will need to look at the parent web directory of the application, change the hostname and leave the uri in tact.
You’re going to have to have 200 lines somewhere, but probably better to do it in a data group. So if I understand you, the new hostname is dependent on the requested parent directory, correct? If so, how about something like this:
Data group (example: “my_datagroup”)
“/parentdirectory1/” := “hostname1”
“/parentdirectory2/” := “hostname2”
…
“/parentdirectory300/” := “hostname300”
iRule:
when HTTP_REQUEST {
if { ( [string tolower [HTTP::host]] equals "hostname.com" ) and ( [class match [string tolower [HTTP::uri]] starts_with my_datagroup] ) } {
HTTP::redirect "http://[class match -value [string tolower [HTTP::uri]] starts_with my_datagroup][HTTP::uri]"
}
}
I’ve also made a giant assumption here that the hostname is the same for all of the old stuff. If not, your data group key might actually be the old hostname and the parent directory.
Kevin, thank you! There are some different hostnames so thank you for including that as well. I will rather do the data groups. I am in the network team and the app dev team wanted to provide me with a CSV file with all the redirects and have teh irule reference the File. I would rather the data group…
Keep in mind that every time you update a data group (class) the iRule may temporarily fail and/or the values will be unavailable for the duration of the update process…
The outright failure of the iRule can be mitigated relatively easily by verifying that the data class does indeed exist and putting the request on hold, but the temporary unavailability of the entries is more difficult to mitigate.
I had to create this on a test F5 which is running version 9.4.6 before performing in production. How do I convert the iRule and Data Group from the version 11 format provided above to the version 9.4.6? I noticed that the “class match” was not available on version 9 and we believe that we have to use “matchclass” instead but we recieved the below error.
i understand string data group in 9.x does not have “value” pair, does it? anyway, if you want, you may be able to add the value to string and parse it yourself.
Is there any performance impact on the site when you have 300 lines in a data group? Just trying to get an idea of what to expect when we start to get to the last pages.
Is there any performance impact on the site when you have 300 lines in a data group? Just trying to get an idea of what to expect when we start to get to the last pages.
you may try irule timing to see how many cpu cycle irule utilizes. anyway, if your unit is not under heavy loaded, i think this irule with 300 lines in data group would be pretty fine.
iRules Optimization 101 - 05 - Evaluating iRule Performance by Deb Allen