Forum Discussion

muzammil_88686's avatar
muzammil_88686
Icon for Nimbostratus rankNimbostratus
Sep 28, 2012

Redirection of URLs

I m trying to redirect the below URLs.

 

 

1)

 

From: http://www.mysite.com/abc/def/ghi/jkl/fiber/?lang=en&resetP=true

 

To: http://www.mysite.com/abc/def/ghi/jkl/broad/?lang=en&resetP=true

 

 

2)

 

From: http://www.mysite.com/abc/def/ghi/jkl/fiber/!ut

 

To: http://www.mysite.com/abc/def/ghi/jkl/broad

 

 

I also have the below friendly URL redirection.

 

===

 

 

when HTTP_REQUEST {

 

 

switch [string tolower [HTTP::host]] {

 

"www.mysite.com" -

 

"mysite.com" -

 

"10.1.1.1" {

 

 

switch -glob [HTTP::path] {

 

"/123" -

 

"*/abc/def/123" { HTTP::redirect "http://www.mysite.com/abc/def/personal/123/?resetP=true" }

 

}

 

}

 

}

 

}

 

===

 

Could you pls tell me if I can accomodate the redirection of two new URLs into the above friendly URL iRule?

 

Could you pls suggest me the iRule either in accomodating in above iRule or new iRule.

 

2 Replies

  • Hi muzammil,

    Try this. Should be easy to make adjustments to if needed.

     
    when HTTP_REQUEST {
        switch -glob [string tolower [HTTP::host]] {
            "www.mysite.com" -
            "mysite.com" -
            "10.1.1.1" {
                switch -glob [string tolower [HTTP::path]] {
                    "/123" -
                    "*/abc/def/123" {
                        HTTP::redirect "http://www.mysite.com/abc/def/personal/123/?resetP=true"
                    }
                    "*/fiber/" {
                        HTTP::redirect "http://[HTTP::host][string map {"/fiber" "/broad"} [HTTP::uri]]"
                    }
                    "*/fiber/!ut" {
                        HTTP::redirect "http://[HTTP::host][string map {"/fiber/!ut" "/broad"} [HTTP::uri]]"
                    }
                }
            }
        }
    }