Forum Discussion

Ramv's avatar
Ramv
Icon for Nimbostratus rankNimbostratus
Oct 07, 2022

iRule creation with redirection condition

Dears, 

I have a requirement to create irule below requirement  If URL is referring to a page that does not end with a "/" or a file ending ".xxx" then redirect to the same URL ending with a "/"

when HTTP_REQUEST {
set req [string tolower [HTTP::path]]
if { !([class match $req ends_with extensions])
or !($req ends_with "/") }
{ HTTP::path "[HTTP::path]/" }
}

Above irule will meet my requirements? addtionaly where I can define the extensions under data group records as below?

ltm data-group internal /Common/extensions {
records {

  • Hi Ramv,

    when HTTP_REQUEST {
    	if { !([class match [string tolower [HTTP::path]] ends_with /Common/extensions]) and !([string tolower [HTTP::path]] ends_with "/") } {
    		HTTP::path "[HTTP::path]/"
    	}
    }

    You can modify the datagroup from Local Traffic ›› iRules ›› Data Group List menu. You can also use the following command.

    tmsh
    modify ltm data-group internal extensions records add { .abc .def .xyz }
    • Ramv's avatar
      Ramv
      Icon for Nimbostratus rankNimbostratus

      Hi Enes, 

      Thanks for responding, I will keep you update once we implement the irule. 

      Regards,

      Ram