# HTTP to HTTPS with a URI and PromoCode

**URL:** <https://community.f5.com/t/http-to-https-with-a-uri-and-promocode/34861>\
**Category:** Technical Forums\
**Tags:** dev, irules, devops, application-delivery\
**Created:** [November 28, 2007, 4:35pm UTC](https://community.f5.com/t/http-to-https-with-a-uri-and-promocode/34861 "2007-11-28T16:35:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rposey\_79430](https://avatars.discourse-cdn.com/v4/letter/r/f19dbf/32.png) [@rposey\_79430](https://community.f5.com/u/rposey_79430)\
**Post date:** [November 28, 2007, 4:35pm UTC](https://community.f5.com/t/http-to-https-with-a-uri-and-promocode/34861/1 "2007-11-28T16:35:17Z")

</div>

I have two scenarios I need iRules written for and I am having trouble finding a forum thread that related to my setup. I have generic HTTP to HTTPS iRules, but nothing that modifies the domain and URI.

==========================================

Scenario 1

! Redirect a HTTP request to HTTPS and append a URI on the redirect.

Example:

[http://ABC.com](http://ABC.com) redirected to [https://ABC.com/Consumer/Login.do](https://ABC.com/Consumer/Login.do)

==========================================

Scenario 2

! Redirect a HTTP request from a specific branded site to a generic HTTPS site with a URI/PromoCode

Example:

[http://ABC.com](http://ABC.com) redirected to [https://genericsite.com/Consumer/Landing.do?promoCode=ABC](https://genericsite.com/Consumer/Landing.do?promoCode=ABC)

==========================================

If someone cold assist me with how this would work I would appreciate it.

---

<div class="post-metadata">

**Author:** ![hoolio](https://avatars.discourse-cdn.com/v4/letter/h/f6c823/32.png) [@hoolio](https://community.f5.com/u/hoolio)\
**Post date:** [November 28, 2007, 4:57pm UTC](https://community.f5.com/t/http-to-https-with-a-uri-and-promocode/34861/2 "2007-11-28T16:57:42Z")

</div>

Here are two rules which do a static redirect for all requests to the same URL. If you want something more dynamic that either of these, can you elaborate on the logic of what to redirect to?

```tcl
Scenario 1, redirect HTTP requests to HTTPS with a modified URI
when HTTP_REQUEST {
   HTTP::redirect https://ABC.com/Consumer/Login.do
}

```

```tcl
Scenario 2, redirect HTTP requests to HTTPS with a modified URI
when HTTP_REQUEST {
   HTTP::redirect https://genericsite.com/Consumer/Landing.do?promoCode=ABC
}

```

Aaron
