# URL redirect

**URL:** <https://community.f5.com/t/url-redirect/12808>\
**Category:** Technical Forums\
**Tags:** devops, ltm\
**Created:** [July 7, 2016, 2:14pm UTC](https://community.f5.com/t/url-redirect/12808 "2016-07-07T14:14:31Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![Greg\_Donohoe\_25](https://avatars.discourse-cdn.com/v4/letter/g/c2a13f/32.png) [@Greg\_Donohoe\_25](https://community.f5.com/u/Greg_Donohoe_25)\
**Post date:** [July 7, 2016, 2:14pm UTC](https://community.f5.com/t/url-redirect/12808/1 "2016-07-07T14:14:31Z")

</div>

Hi, I am trying to configure a URL redirect so that client sessions connectiong to https:abc.home.com are redirected to [https://xyz.office.com.](https://xyz.office.com) The one issue I see is that the [xyz.office.com](http://xyz.office.com) site will have a certificate with that common name included so the client session with the HTTP get of [abc.home.com](http://abc.home.com) will fail. Is there a way to completely change the destination URL within an irule? Or is there any easier way?

---

<div class="post-metadata">

**Author:** ![IainThomson85\_1](https://avatars.discourse-cdn.com/v4/letter/i/edb3f5/32.png) [@IainThomson85\_1](https://community.f5.com/u/IainThomson85_1)\
**Post date:** [July 7, 2016, 2:26pm UTC](https://community.f5.com/t/url-redirect/12808/2 "2016-07-07T14:26:24Z")

</div>

A permanent redirect is what you’re after…

> **[DevCentral - An F5 Technical Community](https://community.f5.com/)**
>
> DevCentral is an online technical community where engineers and practitioners collaborate, share knowledge, and solve problems related to F5 technologies and industry trends.

Should solve your issue.

---

<div class="post-metadata">

**Author:** ![Greg\_Donohoe\_25](https://avatars.discourse-cdn.com/v4/letter/g/c2a13f/32.png) [@Greg\_Donohoe\_25](https://community.f5.com/u/Greg_Donohoe_25)\
**Post date:** [July 7, 2016, 3:02pm UTC](https://community.f5.com/t/url-redirect/12808/3 "2016-07-07T15:02:19Z")

</div>

Thank you for the reply Iain but I dont understand how that can help me? Will that accept HTTP request for https:abc.home.com and redirect them to [https://xyz.office.com](https://xyz.office.com)? What would the syntax look like?

---

<div class="post-metadata">

**Author:** ![Yann\_Desmarest\_1](https://avatars.discourse-cdn.com/v4/letter/y/65b543/32.png) [@Yann\_Desmarest\_1](https://community.f5.com/u/Yann_Desmarest_1)\
**Post date:** [July 7, 2016, 3:35pm UTC](https://community.f5.com/t/url-redirect/12808/4 "2016-07-07T15:35:19Z")

</div>

Hi,

You can use the following :

```tcl
when HTTP_REQUEST {
 if { [HTTP::host] eq "abc.home.com" } {
  HTTP::respond 301 Location "https://xyz.office.com[HTTP::uri]"
 }
}

```

---

<div class="post-metadata">

**Author:** ![Yann\_Desmarest](https://avatars.discourse-cdn.com/v4/letter/y/5fc32e/32.png) [@Yann\_Desmarest](https://community.f5.com/u/Yann_Desmarest)\
**Post date:** [July 7, 2016, 3:35pm UTC](https://community.f5.com/t/url-redirect/12808/5 "2016-07-07T15:35:19Z")

</div>

Hi,

You can use the following :

```tcl
when HTTP_REQUEST {
 if { [HTTP::host] eq "abc.home.com" } {
  HTTP::respond 301 Location "https://xyz.office.com[HTTP::uri]"
 }
}

```

---

<div class="post-metadata">

**Author:** ![Greg\_Donohoe\_25](https://avatars.discourse-cdn.com/v4/letter/g/c2a13f/32.png) [@Greg\_Donohoe\_25](https://community.f5.com/u/Greg_Donohoe_25)\
**Post date:** [July 7, 2016, 6:05pm UTC](https://community.f5.com/t/url-redirect/12808/6 "2016-07-07T18:05:31Z")

</div>

Hi Yann, thanks for the response. Your irule worked perfectly for what I wanted to do but now the application guys have come back with an additional request ☹ There is an authentication server in front of [abc.home.com](http://abc.home.com) and what they want is any connection coming from that server to be allowed through. BUT if someone tries to go direct to [abc.home.com](http://abc.home.com) then they need the redirect to [xyz.office.com](http://xyz.office.com) which you have already suggested. Any ideas? What is the best way to define the authentication server source? Any help appreciated.

---

<div class="post-metadata">

**Author:** ![Greg\_Donohoe\_25](https://avatars.discourse-cdn.com/v4/letter/g/c2a13f/32.png) [@Greg\_Donohoe\_25](https://community.f5.com/u/Greg_Donohoe_25)\
**Post date:** [July 7, 2016, 6:05pm UTC](https://community.f5.com/t/url-redirect/12808/7 "2016-07-07T18:05:31Z")

</div>

Hi Yann, thanks for the response. Your irule worked perfectly for what I wanted to do but now the application guys have come back with an additional request ☹ There is an authentication server in front of [abc.home.com](http://abc.home.com) and what they want is any connection coming from that server to be allowed through. BUT if someone tries to go direct to [abc.home.com](http://abc.home.com) then they need the redirect to [xyz.office.com](http://xyz.office.com) which you have already suggested. Any ideas? What is the best way to define the authentication server source? Any help appreciated.

---

<div class="post-metadata">

**Author:** ![Greg\_Donohoe\_25](https://avatars.discourse-cdn.com/v4/letter/g/c2a13f/32.png) [@Greg\_Donohoe\_25](https://community.f5.com/u/Greg_Donohoe_25)\
**Post date:** [July 7, 2016, 6:12pm UTC](https://community.f5.com/t/url-redirect/12808/8 "2016-07-07T18:12:12Z")

</div>

Just to add to this for better understanding here is the set up: [xyz.office.com](http://xyz.office.com) → authentication server (virtual server) → [abc.home.com](http://abc.home.com) If a connection to [abc.home.com](http://abc.home.com) comes from authentication server they want the connection to pass throug to pool members. If a connection goes from anywhere else direct to [abc.home.com](http://abc.home.com) then they are redirected back to [xyz.office.com](http://xyz.office.com) so that they can authenticate correctly. I hope this is a bit clearer.

---

<div class="post-metadata">

**Author:** ![Greg\_Donohoe\_25](https://avatars.discourse-cdn.com/v4/letter/g/c2a13f/32.png) [@Greg\_Donohoe\_25](https://community.f5.com/u/Greg_Donohoe_25)\
**Post date:** [July 7, 2016, 6:12pm UTC](https://community.f5.com/t/url-redirect/12808/9 "2016-07-07T18:12:12Z")

</div>

Just to add to this for better understanding here is the set up: [xyz.office.com](http://xyz.office.com) → authentication server (virtual server) → [abc.home.com](http://abc.home.com) If a connection to [abc.home.com](http://abc.home.com) comes from authentication server they want the connection to pass throug to pool members. If a connection goes from anywhere else direct to [abc.home.com](http://abc.home.com) then they are redirected back to [xyz.office.com](http://xyz.office.com) so that they can authenticate correctly. I hope this is a bit clearer.

---

<div class="post-metadata">

**Author:** ![Yann\_Desmarest\_1](https://avatars.discourse-cdn.com/v4/letter/y/65b543/32.png) [@Yann\_Desmarest\_1](https://community.f5.com/u/Yann_Desmarest_1)\
**Post date:** [July 7, 2016, 6:57pm UTC](https://community.f5.com/t/url-redirect/12808/10 "2016-07-07T18:57:44Z")

</div>

Hi, you should use APM and external logon page.

---

<div class="post-metadata">

**Author:** ![Yann\_Desmarest](https://avatars.discourse-cdn.com/v4/letter/y/5fc32e/32.png) [@Yann\_Desmarest](https://community.f5.com/u/Yann_Desmarest)\
**Post date:** [July 7, 2016, 6:57pm UTC](https://community.f5.com/t/url-redirect/12808/11 "2016-07-07T18:57:44Z")

</div>

Hi, you should use APM and external logon page.

---

<div class="post-metadata">

**Author:** ![Yann\_Desmarest\_1](https://avatars.discourse-cdn.com/v4/letter/y/65b543/32.png) [@Yann\_Desmarest\_1](https://community.f5.com/u/Yann_Desmarest_1)\
**Post date:** [July 7, 2016, 7:00pm UTC](https://community.f5.com/t/url-redirect/12808/12 "2016-07-07T19:00:38Z")

</div>

Basically, you need to make sure that the user has been authenticated. So, my first recommendation would be to use APM module

---

<div class="post-metadata">

**Author:** ![Yann\_Desmarest](https://avatars.discourse-cdn.com/v4/letter/y/5fc32e/32.png) [@Yann\_Desmarest](https://community.f5.com/u/Yann_Desmarest)\
**Post date:** [July 7, 2016, 7:00pm UTC](https://community.f5.com/t/url-redirect/12808/13 "2016-07-07T19:00:38Z")

</div>

Basically, you need to make sure that the user has been authenticated. So, my first recommendation would be to use APM module

---

<div class="post-metadata">

**Author:** ![Yann\_Desmarest](https://avatars.discourse-cdn.com/v4/letter/y/5fc32e/32.png) [@Yann\_Desmarest](https://community.f5.com/u/Yann_Desmarest)\
**Post date:** [July 7, 2016, 7:02pm UTC](https://community.f5.com/t/url-redirect/12808/14 "2016-07-07T19:02:35Z")

</div>

Without APM, maybe you can check the presence of a cookie delivered by the authentication system and/or use sideband connections to do a lookup on the external authentication system

---

<div class="post-metadata">

**Author:** ![Yann\_Desmarest\_1](https://avatars.discourse-cdn.com/v4/letter/y/65b543/32.png) [@Yann\_Desmarest\_1](https://community.f5.com/u/Yann_Desmarest_1)\
**Post date:** [July 7, 2016, 7:02pm UTC](https://community.f5.com/t/url-redirect/12808/15 "2016-07-07T19:02:35Z")

</div>

Without APM, maybe you can check the presence of a cookie delivered by the authentication system and/or use sideband connections to do a lookup on the external authentication system
