# Replace URL string

**URL:** <https://community.f5.com/t/replace-url-string/25811>\
**Category:** Technical Forums\
**Tags:** irules, devops, ltm, application-delivery\
**Created:** [June 4, 2014, 2:05pm UTC](https://community.f5.com/t/replace-url-string/25811 "2014-06-04T14:05:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sistemaspcs\_851](https://avatars.discourse-cdn.com/v4/letter/s/5f8ce5/32.png) [@sistemaspcs\_851](https://community.f5.com/u/sistemaspcs_851)\
**Post date:** [June 4, 2014, 2:05pm UTC](https://community.f5.com/t/replace-url-string/25811/1 "2014-06-04T14:05:31Z")

</div>

Hello, I want to replace a string from URL, in this case the server behind the BIG-IP returns this url [http://AAA.XXXX.net/common/Account/Login?ReturnUrl=http%3A%2F%2FAAA.XXXX.net%2Froadtransport%2F](http://AAA.XXXX.net/common/Account/Login?ReturnUrl=http%3A%2F%2FAAA.XXXX.net%2Froadtransport%2F) I want to rewrite it to: http **s** ://AAA.XXXX.net/common/Account/Login?ReturnUrl= **https** %3A%2F%[2FAAA.XXXX.net](http://2FAAA.XXXX.net)%2Froadtransport%2F In the user´s browser

Is it possible? I was thinking in something like this:

```tcl
when HTTP_REQUEST {
     if { [string tolower [HTTP::path]] contains "ReturnUrl" } {
          HTTP::redirect [string map {"http" "https"} [HTTP::uri]]
     }
}

```

But I don´t know if I´m in the right way. Any idea to solve this problem?

---

<div class="post-metadata">

**Author:** ![sistemaspcs\_851](https://avatars.discourse-cdn.com/v4/letter/s/5f8ce5/32.png) [@sistemaspcs\_851](https://community.f5.com/u/sistemaspcs_851)\
**Post date:** [June 5, 2014, 6:51am UTC](https://community.f5.com/t/replace-url-string/25811/2 "2014-06-05T06:51:24Z")

</div>

Finally I achieve it with this irule in the ssl virtual server

```tcl
when HTTP_RESPONSE {
     if { [HTTP::header Location] contains "ReturnUrl" }{
     HTTP::header replace Location "[string map {"ReturnUrl=http" "ReturnUrl=https"} [HTTP::header Location]]"
    }
}

```
