Forum Discussion

mika's avatar
mika
Icon for Cirrus rankCirrus
Jul 28, 2020

redirect path irule f5

Hello!

I have three hosts ( www.abc.com /.www.aze.fr / www.qsd.fr ) with the same path and i want redirect all the paths to a new path for all hosts

My irule:

when HTTP_REQUEST {

if { 

  [HTTP::path] contains "/abcd" 

 or [HTTP::path] contains "/yyyyyyy" 

or [HTTP::path] contains "/xxxxxx" 

or [HTTP::path] contains "/zzzzzz" 

...

}

{

     HTTP::redirect "/fin_participations.html" 

}

}

But my irule it's not good, have you suggestions to achieve my goal please!!

Thank you ^_^

 

 

6 Replies

  • Hi mika,

    when HTTP_REQUEST {
    	if { [string tolower [HTTP::uri]] ne "/fin_participations.html" } {
    		HTTP::redirect "http://www.abc.com/fin_participations.html"
    	}
    }
    • mika's avatar
      mika
      Icon for Cirrus rankCirrus

       

      thank you for your reply, but I cannot apply this rule because I have another url with the same hosts that I don't want to redirect to this page, i want redirect just some path not all.

       

       

       

      • You can use switch statement or datagroup.

        Switch:

        when HTTP_REQUEST {
        	switch -glob [HTTP::path] {
        		"/abcd*" -
        		"/yyyyyyy*" -
        		"/xxxxxx*" -
        		"/zzzzzz*" { HTTP::redirect "http://[HTTP::host]/fin_participations.html" }
        	}
        }

        Datagroup:

        Create a string datagroup.

        /abcd
        /yyyyyyy
        /xxxxxx
        /zzzzzz

        Datagroup irule:

        when HTTP_REQUEST {
        	if { class match [HTTP::path] contains dg-name } {
        		HTTP::redirect "http://[HTTP::host]/fin_participations.html" }
        	}
        }
    • mika's avatar
      mika
      Icon for Cirrus rankCirrus

      Hello, thank u for your reply, i created a datagroup which contains all path, and i used

      LTM Policy refer attached image but i have the same probleme.

       

      Best regards