# HTTPS Rewrite Failing

**URL:** <https://community.a10networks.com/t/https-rewrite-failing/317>\
**Category:** aFleX\
**Created:** [April 22, 2015, 3:03pm UTC](https://community.a10networks.com/t/https-rewrite-failing/317 "2015-04-22T15:03:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![spirrello](https://avatars.discourse-cdn.com/v4/letter/s/a9adbd/32.png) [@spirrello](https://community.a10networks.com/u/spirrello)\
**Post date:** [April 22, 2015, 3:03pm UTC](https://community.a10networks.com/t/https-rewrite-failing/317/1 "2015-04-22T15:03:28Z")

</div>

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?

```auto
when HTTP\_REQUEST \{
\# Force servers to not reply with compression (compression can be enabled on the AX)

```

HTTP::header remove Accept-Encoding

```auto
\}

when HTTP\_RESPONSE \{

```

# Test if the servers are sending a redirect and if so rewrite the redirect with https

```auto
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

```auto
\}
\}

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  
}

---

<div class="post-metadata">

**Author:** ![spirrello](https://avatars.discourse-cdn.com/v4/letter/s/a9adbd/32.png) [@spirrello](https://community.a10networks.com/u/spirrello)\
**Post date:** [April 22, 2015, 4:00pm UTC](https://community.a10networks.com/t/https-rewrite-failing/317/2 "2015-04-22T16:00:46Z")

</div>

Got this resolved by following this posting. Thanks Ddesmidt!!!

[https://dev-a10wp.pantheonsite.io/index.php/forums/topic/making-a-http-site-https/](https://dev-a10wp.pantheonsite.io/index.php/forums/topic/making-a-http-site-https/)
