Options

HTTPS Rewrite Failing

spirrellospirrello Member
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
}

Comments

Sign In or Register to comment.