# Domain Redirect

**URL:** <https://community.f5.com/t/domain-redirect/4141>\
**Category:** Technical Forums\
**Tags:** dev, irules, devops, application-delivery\
**Created:** [November 2, 2009, 2:05pm UTC](https://community.f5.com/t/domain-redirect/4141 "2009-11-02T14:05:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bvinson\_12764](https://avatars.discourse-cdn.com/v4/letter/b/65b543/32.png) [@bvinson\_12764](https://community.f5.com/u/bvinson_12764)\
**Post date:** [November 2, 2009, 2:05pm UTC](https://community.f5.com/t/domain-redirect/4141/1 "2009-11-02T14:05:40Z")

</div>

Hello,

Pretty new to Irules,

How do I,

I have a new domain and a old domain that point to the same Web services.

lets call them [new.com](http://new.com) and [old.com](http://old.com)

I would like it when users access [web.old.com](http://web.old.com) to be redirected to [web.new.com](http://web.new.com). I need the name change because of SSL naming.

Any suggestions?

Many Thanks

You guys are awesome

😃

---

<div class="post-metadata">

**Author:** ![The\_Bhattman](https://d1p9zq3aats0t8.cloudfront.net/user_avatar/community.f5.com/the_bhattman/32/13958_2.png) [@The\_Bhattman](https://community.f5.com/u/The_Bhattman)\
**Post date:** [November 2, 2009, 2:54pm UTC](https://community.f5.com/t/domain-redirect/4141/2 "2009-11-02T14:54:14Z")

</div>

Here is a simple redirection of a domain name

```tcl
when HTTP_REQUEST { 
    if {[HTTP::host] eq "web.old.com" } { 
       HTTP::redirect "http://web.new.com/[HTTP::uri]/" 
       } 
 }

```

I hope this helps

CB

---

<div class="post-metadata">

**Author:** ![bvinson\_12764](https://avatars.discourse-cdn.com/v4/letter/b/65b543/32.png) [@bvinson\_12764](https://community.f5.com/u/bvinson_12764)\
**Post date:** [November 2, 2009, 4:15pm UTC](https://community.f5.com/t/domain-redirect/4141/3 "2009-11-02T16:15:27Z")

</div>

Thanks for the response;

is there a way to build on for a general domain.

by that I mean one that could be used for any host

\*.old.com to \*.new.com?

---

<div class="post-metadata">

**Author:** ![The\_Bhattman](https://d1p9zq3aats0t8.cloudfront.net/user_avatar/community.f5.com/the_bhattman/32/13958_2.png) [@The\_Bhattman](https://community.f5.com/u/The_Bhattman)\
**Post date:** [November 2, 2009, 4:28pm UTC](https://community.f5.com/t/domain-redirect/4141/4 "2009-11-02T16:28:31Z")

</div>

I suppose you can do the following

```tcl
when HTTP_REQUEST { 
   if { [HTTP::host] contains "old.com"} { 
     HTTP::redirect http://[getfield [HTTP::host] ".old.com" 1].new.com[HTTP::uri] 
   } 
 }

```
