# How to redirect non www to www

**URL:** <https://community.f5.com/t/how-to-redirect-non-www-to-www/55302>\
**Category:** Technical Forums\
**Tags:** irules, ltm, application-delivery\
**Created:** [December 3, 2019, 1:33pm UTC](https://community.f5.com/t/how-to-redirect-non-www-to-www/55302 "2019-12-03T13:33:28Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dan44](https://avatars.discourse-cdn.com/v4/letter/d/ecc23a/32.png) [@Dan44](https://community.f5.com/u/Dan44)\
**Post date:** [December 3, 2019, 1:33pm UTC](https://community.f5.com/t/how-to-redirect-non-www-to-www/55302/1 "2019-12-03T13:33:28Z")

</div>

Hi community

i have a virtual server (port 443) and i would like to create a iRule that redirects from non www to www

After enabling the iRule the Browser (Firefox, Chrome) says: PR\_CONNECT\_RESET\_ERROR.

i have tried with:

```tcl
when HTTP_REQUEST {
   if {  [HTTP::host] ne "www.mydomain.com" } {
      HTTP::respond 301 Location "https:/www.mydomain.com"
   }

}

```

---

<div class="post-metadata">

**Author:** ![cjunior](https://avatars.discourse-cdn.com/v4/letter/c/779978/32.png) [@cjunior](https://community.f5.com/u/cjunior)\
**Post date:** [December 3, 2019, 2:07pm UTC](https://community.f5.com/t/how-to-redirect-non-www-to-www/55302/2 "2019-12-03T14:07:14Z")

</div>

Hi,

Do you have any client SSL attached to the virtual server?

It sounds like you are not decrypting packets before read or write that.

Regards

---

<div class="post-metadata">

**Author:** ![Dan44](https://avatars.discourse-cdn.com/v4/letter/d/ecc23a/32.png) [@Dan44](https://community.f5.com/u/Dan44)\
**Post date:** [December 3, 2019, 2:19pm UTC](https://community.f5.com/t/how-to-redirect-non-www-to-www/55302/3 "2019-12-03T14:19:46Z")

</div>

hi cjunior,

yes, we have a client ssl profile attached to the VS. we are doing SSL offlaoding.

regards

---

<div class="post-metadata">

**Author:** ![cjunior](https://avatars.discourse-cdn.com/v4/letter/c/779978/32.png) [@cjunior](https://community.f5.com/u/cjunior)\
**Post date:** [December 3, 2019, 3:08pm UTC](https://community.f5.com/t/how-to-redirect-non-www-to-www/55302/4 "2019-12-03T15:08:32Z")

</div>

OK, sorry the inconvenience.

So if you remove your iRule it back to works? Didi you catch some execution error on LTM log?

I don’t think this single slash typo “https:/www” affect that, but 😕

Maybe you can try running command line on bash to know if the problem is on your browser.

10.10.10.10 = replace with your VS IP address

Did you get the HTTP 301 and new location running this?

```tcl
curl -kv --resolve other.mydomain.com:443:10.10.10.10 https://other.mydomain.com

```

Did you get any issue running this?

```tcl
curl -v --resolve www.mydomain.com:443:10.10.10.10 https://www.mydomain.com

```

Regards

---

<div class="post-metadata">

**Author:** ![Dan44](https://avatars.discourse-cdn.com/v4/letter/d/ecc23a/32.png) [@Dan44](https://community.f5.com/u/Dan44)\
**Post date:** [December 4, 2019, 6:42am UTC](https://community.f5.com/t/how-to-redirect-non-www-to-www/55302/5 "2019-12-04T06:42:30Z")

</div>

hi

we will add some logs in the Irule for better debugging. We think there is a conflict between the redirect on the LTM and a redirect locally on the web server. We are now investigating with the developers. thx
