Hi All,
I am looking for irule to achieve below result.
1. stg.gr.com/content/ga/en/page.html --- content uri should be removed and ga/en should merged in form of /en-ga/
to be 301 redirected to stg.gr.com/en-qa/page.html
e.g. stg.gr.com/content/ga/en/homepage.html to stg.gr.com/en-ga/homepage.html
e.g. stg.gr.com/content/fr/en/homepage.html to stg.gr.com/en-fr/homepage.html
e.g. stg.gr.com/content/ka/en/homepage.html to stg.gr.com/en-ka/homepage.html
similar like /ga/ there are other uris
Appreciate help .
Thanks in advance.
Try this
when HTTP_REQUEST {
if {[HTTP::uri] starts_with "/content"} {
set field2 [getfield [HTTP::uri] / 3]
set field3 [getfield [HTTP::uri] / 4]
set mergedFields ${field3}-${field2}
set removeContent [string map [list "/content" ""][HTTP::uri]]
set newUri [string map [list "${field2}/${field3}" $mergedFields][HTTP::uri]]
HTTP::redirect https://[HTTP::host]$newUri
}
}
Try this code:
when HTTP_REQUEST {
if {[scan $uri {/content/%[^/]/%[^/]/%s} language1 language2 other] == 3 } {
HTTP::respond 301 Location "/$language2-$language1/$other"
}
}
This gives error for line no.6
Add a space just before [HTTP::uri]