# Traefik 2.2 Regex

**URL:** <https://community.traefik.io/t/traefik-2-2-regex/7020>\
**Category:** Traefik v2\
**Tags:** file, middleware, docker\
**Created:** [July 21, 2020, 3:23pm UTC](https://community.traefik.io/t/traefik-2-2-regex/7020 "2020-07-21T15:23:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![leonfilser](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/leonfilser/32/1964_2.png) [@leonfilser](https://community.traefik.io/u/leonfilser)\
**Post date:** [July 21, 2020, 3:23pm UTC](https://community.traefik.io/t/traefik-2-2-regex/7020/1 "2020-07-21T15:23:13Z")

</div>

Hello!

I am trying to redirect (http:// and https://)[domain.com](http://domain.com) and also (http:// and https://)[www.domain.com](http://www.domain.com) to [google.com](http://google.com).

I thougt I figured it out by doing the following:

```auto
   [http.middlewares]
     [http.middlewares.redirect.redirectRegex]
       regex = "(.*)domain.com(.*)"
       replacement = "google.com${2}"
       permanent = true

```

But instead of redirecting me to [google.com](http://google.com) Traefik redirects me to [domain.com/google.com/google.com/google.com](http://domain.com/google.com/google.com/google.com) .... and so on

I tested my config with [regex101](https://regex101.com) and it looked fine there but obviously its not working with Traefik.

Does anyone have a bit more experience with Regex?  
Thanks in Advance!

---

<div class="post-metadata">

**Author:** ![leonfilser](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/leonfilser/32/1964_2.png) [@leonfilser](https://community.traefik.io/u/leonfilser)\
**Post date:** [July 22, 2020, 7:54am UTC](https://community.traefik.io/t/traefik-2-2-regex/7020/2 "2020-07-22T07:54:03Z")

</div>

Now it works with this config:

```auto
   [http.middlewares]
     [http.middlewares.redirect.redirectRegex]
       regex = "(.*)domain.com(.*)"
       replacement = "http://google.com"
       permanent = true

```
