Forum Discussion

jmartinez_44554's avatar
jmartinez_44554
Icon for Nimbostratus rankNimbostratus
Feb 07, 2014

Redirects with multiple params

I'm trying to redirect the following uri and not having any success. I want to keep the second param and remove the first one.

 

http://domain.com/techsupport/nontemplates/Download%20Center/DownloadCenter.aspx?Download_content=User+Manuals&download_product=A660DF1A-91FF-445B-8125-CE49DF253C64

 

This the code I'm using. Other redirects are working fine but they have no params or only one.

 

when HTTP_REQUEST { set myUri [HTTP::uri] set myHost [HTTP::host] switch -glob [string tolower [HTTP::uri]] {

 

"/techsupport/nontemplates/Download%20Center/DownloadCenter.aspx?Download_content=User+Manuals&download_product*" { set newURI [string map -nocase {"/techsupport/nontemplates/Download%20Center/DownloadCenter.aspx?Download_content=User+Manuals&download_product=" "/Redirect/Content/User+Manuals/Product/"} [HTTP::uri]] log local0. "redirecting to http://[HTTP::host]$newURI" HTTP::redirect "http://[HTTP::host]$newURI } }

 

2 Replies

  • the switch's string is set to lowercase but pattern is not.

    e.g.

    [root@ve11a:Active:In Sync] config  tmsh list ltm rule myrule
    ltm rule myrule {
        when HTTP_REQUEST {
      switch -glob [HTTP::uri] {
        "/techsupport/nontemplates/Download%20Center/DownloadCenter.aspx?Download_content=User+Manuals&download_product*" {
          set newURI [string map -nocase {"/techsupport/nontemplates/Download%20Center/DownloadCenter.aspx?Download_content=User+Manuals&download_product=" "/Redirect/Content/User+Manuals/Product/"} [HTTP::uri]]
          HTTP::redirect "http://[HTTP::host]$newURI"
        }
      }
    }
    }
    
    [root@ve11a:Active:In Sync] config  curl -I "http://172.28.24.10/techsupport/nontemplates/Download%20Center/DownloadCenter.aspx?Download_content=User+Manuals&download_product=A660DF1A-91FF-445B-8125-CE49DF253C64"
    HTTP/1.0 302 Found
    Location: http://172.28.24.10/Redirect/Content/User+Manuals/Product/A660DF1A-91FF-445B-8125-CE49DF253C64
    Server: BigIP
    Connection: Keep-Alive
    Content-Length: 0