Forum Discussion

Piergiorgio_Pas's avatar
Piergiorgio_Pas
Icon for Nimbostratus rankNimbostratus
Aug 26, 2016

Manipulate Uri for Rewrite

Hi I have to manipulate this type of call www.something.it/site/one/two/three

 

to make it this way www.something.it/site?AAA=one?BBB=two?CCC=three

 

After the word site the other fields are transformed into variables to be passed to rewrite

 

Can someone help me?

 

Thanks

 

Pg

 

1 Reply

  • Hi,

    you can try this irule:

    when HTTP_REQUEST {
        if {[regexp {^(.*\/site)\/(.*)$} [HTTP::path] fulllpath baseurl myfields]} {
            set fields [split $myfields "/"]
            set query ""
            foreach field $fields param {AAA BBB CCC DDD EEE FFF GGG HHH III JJJ KKK LLL MMM NNN OOO} {
                if {$field == ""} {break}
                append query "$param=$field&"
            }
            set query [string trimright $query "&"]
            HTTP::uri "$baseurl?$query"
        }
    }