# irules redirection and something extra

**URL:** <https://community.f5.com/t/irules-redirection-and-something-extra/38364>\
**Category:** Technical Forums\
**Tags:** irules, devops, application-delivery\
**Created:** [December 24, 2013, 1:06am UTC](https://community.f5.com/t/irules-redirection-and-something-extra/38364 "2013-12-24T01:06:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![F5Zan\_89516](https://avatars.discourse-cdn.com/v4/letter/f/b2d939/32.png) [@F5Zan\_89516](https://community.f5.com/u/F5Zan_89516)\
**Post date:** [December 24, 2013, 1:06am UTC](https://community.f5.com/t/irules-redirection-and-something-extra/38364/1 "2013-12-24T01:06:55Z")

</div>

I have a requirement for creating an irule which will add the site id to the forwarded url on https The iRule should redirect requests for

[cmsint-qa.abc.com/public/header.html?SiteId=GCR](http://cmsint-qa.abc.com/public/header.html?SiteId=GCR)

To

[https://gcr-qa.abc.com/public/header.html](https://gcr-qa.abc.com/public/header.html)

If the rule can be written in such a way that the SiteId is added to “-qa.abc.com/public/header.html” with HTTPS

Any help would be appreciated

---

<div class="post-metadata">

**Author:** ![Kevin\_Stewart](https://d1p9zq3aats0t8.cloudfront.net/user_avatar/community.f5.com/kevin_stewart/32/15267_2.png) [@Kevin\_Stewart](https://community.f5.com/u/Kevin_Stewart)\
**Post date:** [December 24, 2013, 2:39am UTC](https://community.f5.com/t/irules-redirection-and-something-extra/38364/2 "2013-12-24T02:39:54Z")

</div>

How about something like this:

```tcl
when HTTP_REQUEST {
    if { not ( [URI::query [string tolower [HTTP::uri]] siteid] equals "" ) } {
        set siteid [URI::query [string tolower [HTTP::uri]] siteid]
        HTTP::redirect "https://${siteid}-qa.abc.com/public/header.html"
    }
}

```

---

<div class="post-metadata">

**Author:** ![F5Zan\_89516](https://avatars.discourse-cdn.com/v4/letter/f/b2d939/32.png) [@F5Zan\_89516](https://community.f5.com/u/F5Zan_89516)\
**Post date:** [December 24, 2013, 3:06am UTC](https://community.f5.com/t/irules-redirection-and-something-extra/38364/3 "2013-12-24T03:06:30Z")

</div>

Thanks Kevin So this whole piece of code is forwarding the URL and adding the site id to the forwarded url header.html as well?

---

<div class="post-metadata">

**Author:** ![Kevin\_Stewart](https://d1p9zq3aats0t8.cloudfront.net/user_avatar/community.f5.com/kevin_stewart/32/15267_2.png) [@Kevin\_Stewart](https://community.f5.com/u/Kevin_Stewart)\
**Post date:** [December 24, 2013, 11:59am UTC](https://community.f5.com/t/irules-redirection-and-something-extra/38364/4 "2013-12-24T11:59:43Z")

</div>

If the request URI contains a “siteid” query string, it is redirected to the new URI.
