Hi,
I’m trying to enable the following Aflex script to rewrite all HTTP responses from the web server to HTTPS. I keep getting a syntax error from the A10 on the line with “if {([HTTP::header “Location”] starts_with…”. Can someone please help?
when HTTP\_REQUEST \{
\# Force servers to not reply with compression (compression can be enabled on the AX)
HTTP::header remove Accept-Encoding
\}
when HTTP\_RESPONSE \{
# Test if the servers are sending a redirect and if so rewrite the redirect with https
if \{ [HTTP::header exists "Location"]\} \{
if \{([HTTP::header "Location"] starts\_with “http://www.example.com”)\} \{
HTTP::header replace Location [string map \{“http://www.example.com” “https://www.example.com”\} [HTTP::header Location]]
\}
\}
# Collect http response if the response time is text based to rewrite absolute links
if { [HTTP::header “Content-Type”] starts_with “text” } {
HTTP::collect
\}
\}
when HTTP\_RESPONSE\_DATA \{
\# Rewrite absolute links from http://www.example.com/* to https://www.example.com/*
set payload\_length [HTTP::payload length]
HTTP::payload replace 0 $payload\_length [string map \{“http://www.example.com” “https://www.example.com”\} [HTTP::payload]]
HTTP::release
}