Redirect when HTTP_RESPONSE [HTTP::status] contains "200"

LeandroLeandro Member
I need to set up a script that does redirection when there was status code 200 for the same page with dynamic context for example https://myURL.com/xtyfwdk


I set the following script but has error

Error : aFleX compile error : line 15: "command is invalid in current event context [ HTTP :: uri ]"

used script

When HTTP_RESPONSE {
if { [ HTTP :: Status] contains " 200 "} {
HTTP :: redirect " https://myurl.com[HTTP::uri]"
}
}

But when I set for a Static page works

When HTTP_RESPONSE {
if { [ HTTP :: Status] contains " 200 "} {
HTTP :: redirect " https://myurl.com/project/ "
}
}
Tagged:

Comments

  • edited April 2016
    Hi Leandro,

    Aflex command HTTP::URI valid events are HTTP_REQUEST and HTTP_REQUEST_DATA, that's why you are getting that error.

    What about something like this?


    when HTTP_REQUEST {
    set uri [HTTP::uri]
    }

    when HTTP_RESPONSE {
    if { [HTTP::status] contains "200" } {
    HTTP::redirect "https://myurl.com$uri"
    }
    }

    Kind regards,
    Daniel.
Sign In or Register to comment.