Forum Discussion

sstorholm's avatar
sstorholm
Icon for Nimbostratus rankNimbostratus
Mar 11, 2022

URL Rewrite in LTM Policy

I have an issue that after an update to a web application the IIS rewrite rules no longer work, so I thought I'd migrate the whole thing over the our F5s that are already doing TLS for the site. 

What I'm trying to do is the following:

finnishapp.domain.com -> 192.0.2.10/appname/ (alternatively 192.0.2.10/appname/?language=fi)
swedishapp.domain.com -> 192.0.2.10/appname/?language=sve

I already have a policy that matches the domain and forwards the request to the server in question, and the server listens to *:80

So the question becomes, what should I add to the policy to make it add the /appname/ part to the request, and also the language parameter for the different subpages. Also there's the edge case that the user might click on a link to change the language on the site itself, adding the ?language= parameter allover again, which should work. Aka. the following for example:

swedishapp.domain.com/?language=en -> 192.0.2.10/appname/?language=en

The site supports en, fi and sve incase it's of importance. 

Or do I need to go fullbore with iRules for this?

2 Replies

  • Hello, this is the most basic I can come up with assuming that finnish language append is optional.

    • I've wrote this on mobile, there might be typos, lmk

     

    when HTTP_REQUEST {

    set lan ""

    if {[HTTP::uri] ends_with "?language=en"}{

    set lan "?language=en"

    } elseif {[HTTP::host] eq "swedishapp.domain.com" }{set lan "?language=sve"}

     HTTP::header replace "Host" "192.0.2.10"

    HTTP::uri "/appname/$lan" 

    }

    • CA_Valli's avatar
      CA_Valli
      Icon for MVP rankMVP

      Reading request again I noticed you mentioned you have an ltm policy for host rewrite, eventually remove the http header instruction as it might clash with ltm policy statements

      (try not to have conflicts on instructions as is might result in unexpected behavior)

       

      also if finnish language is required you can change the default $lan value from "" to "?language=fin" at variable set instruction time,