Forum Discussion
wadeziegler
Nimbostratus
Mar 22, 2022Change a query parameter
I have a query paremeter with coordinates that need to be reversed. The name of the parameter needs to change and the coordinates reversed too. What is the best way to do that?
Change from:
https://gis.xxxxxxxx.com/arcgis/apps/webappviewer/index.html?id=yyyyyyyyy&reversedmarker=36.121779,-115.169858&level=20
To:
https://gis.xxxxxxxx.com/arcgis/apps/webappviewer/index.html?id=yyyyyyyyy&marker=-115.169858,36.121779&level=20
1 Reply
Sort By
Hi wadeziegler,
Can you try this?
when HTTP_REQUEST { if { [HTTP::query] contains "reversedmarker" } { set uri [HTTP::uri] set reversedmarkervalue [URI::query $uri reversedmarker] set markervalue "[getfield $reversedmarkervalue "," 2],[getfield $reversedmarkervalue "," 1]" set newuri [string map [list $reversedmarkervalue $markervalue "reversedmarker" "marker" ] $uri] HTTP::uri $newuri # for redirect # HTTP::redirect https://[HTTP::host]$newuri unset uri reversedmarkervalue markervalue newuri } }
or shorter but less readable:
when HTTP_REQUEST { if { [HTTP::query] contains "reversedmarker" } { HTTP::uri [string map [list "[URI::query [HTTP::uri] reversedmarker]" "[getfield [URI::query [HTTP::uri] reversedmarker] "," 2],[getfield [URI::query [HTTP::uri] reversedmarker] "," 1]" "reversedmarker" "marker"] [HTTP::uri]] # for redirect # HTTP::redirect https://[HTTP::host][string map [list "[URI::query [HTTP::uri] reversedmarker]" "[getfield [URI::query [HTTP::uri] reversedmarker] "," 2],[getfield [URI::query [HTTP::uri] reversedmarker] "," 1]" "reversedmarker" "marker"] [HTTP::uri]] } }
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects