Technical Forum
Ask questions. Discover Answers.
cancel
Showing results for 
Search instead for 
Did you mean: 

iRule creation with redirection condition

Ramv
Nimbostratus
Nimbostratus

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 {

2 REPLIES 2

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 }

Hi Enes, 

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

Regards,

Ram