Redirection from www to non-www

Ahoy,

Does anyone know how to redirect one specific container from www to a non-www domain over https? Im having hard time configuring this.

https://docs.traefik.io/configuration/entrypoints/#rewriting-url

Aren't the theses regex and replacement directives applied to an entire entrypoint (entryPoints.http.redirect)?
I am guessing yassine.laz want's it for a specific frontend?

Exactly, just for a specific frontend.

[entryPoints.https]
    address = ":443"

    [entryPoints.https.redirect]
      regex = "^https://www.(.*)"
      replacement = "https://$1"
      permanent = true

This will redirect the hostname only but removes forward slashes from any URI:

https://www.example.com   >>> https://example.com  
https://www.example.com/article1   >>> https://example.comarticle1  (missing forward slash)

1 Like

No it does not remove forward slashes, at least not in v1.7.12. There is something else you are not showing that you are doing wrong.

1 Like

Will check the Nginx configuration inside the container then.

@zespri Did they remove URL rewriting or just change the location of that doc?

@TrafikJam not sure. I don't have evidence of either.