Forum Discussion
Stephen_Winter
Jun 05, 2021Nimbostratus
Having issue with String Map using variables/data group.
We are doing a migration of our local intranet set to the cloud and we want to redirect people to the new site in stages. The main problem is that the paths are changing slightly on some sites, som...
- Jun 05, 2021
To use variable with string map, it expects list argument. Also no curly braces for defining variables. Try below code
when HTTP_REQUEST { log local0. "Request URL: [HTTP::host][HTTP::uri]" if { [class match [HTTP::uri] starts_with intranet_redirect_datagroup] } { set full_uri [HTTP::uri] log local0. "full URI - $full_uri" set old_uri [class match -name [HTTP::uri] starts_with intranet_redirect_datagroup] set new_uri [class match -value [HTTP::uri] starts_with intranet_redirect_datagroup] log local0. "old_uri - $old_uri" log local0. "new_uri - $new_uri" set rewrite_uri [string map [list "$old_uri" "$new_uri"] [HTTP::uri]] log local0. "New full URI - $rewrite_uri" HTTP::respond 302 Location "https://cloud1.sharepoint.com$rewrite_uri" " return } }
spalande
Jun 05, 2021Nacreous
To use variable with string map, it expects list argument. Also no curly braces for defining variables. Try below code
when HTTP_REQUEST {
log local0. "Request URL: [HTTP::host][HTTP::uri]"
if { [class match [HTTP::uri] starts_with intranet_redirect_datagroup] } {
set full_uri [HTTP::uri]
log local0. "full URI - $full_uri"
set old_uri [class match -name [HTTP::uri] starts_with intranet_redirect_datagroup]
set new_uri [class match -value [HTTP::uri] starts_with intranet_redirect_datagroup]
log local0. "old_uri - $old_uri"
log local0. "new_uri - $new_uri"
set rewrite_uri [string map [list "$old_uri" "$new_uri"] [HTTP::uri]]
log local0. "New full URI - $rewrite_uri"
HTTP::respond 302 Location "https://cloud1.sharepoint.com$rewrite_uri" "
return
}
}
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