Many people type www in front of the domain name out of habit. At the same time, others omit it. This could cause problems.

As a webmaster, it is my job to make sure that neither of these groups run into an error. However, I don’t want to support both versions for every single page search engine optimization reasons.

Multiple domains for the same content is bad for Your SEO ranking. Search engines count links pointing to Your URLs. However, they don’t know whether and are the same website, so they treat them as different entities. If You have 5 backlinks to www and 5 backlinks to `non-www, another site with 7 backlinks will rank higher than Your two URLs, although You actually have 10 total. According to Semrush, each subdomain has its own ranking.

The solution to this problem is to redirect users from one version to the other with an “HTTP 301 redirect” status code. This will A) cause the browser to change the URL so when they copy the URL, they will copy the same one and B) will tell the search engine that these two links are identical.

In order to do this with the NGINX Ingress Controller You can use the from-to-www-redirect annotation in your ingress YAML file: "true"

Keep in mind that You will still need an HTTPS certificate for both versions. However, in Your ingress YAML file, its enough to just define the path that You want. If You define both paths, then the redirect won’t work.

So in my example, I want people who enter to be redirected to the domain Here is my full ingress rule:


kind: ingress
  name: crossquiz-ingress
  annotations: nginx /$1 "true" "true" letsencrypt
    - hosts:
      secretname: tls-secret
    - host:
          - backend:
                name: crossquiz
                  number: 80
            path: /(.*)
            pathtype: implementationspecific

This might be a bit different in Your case, but the important part is that You have:

  • the annotation "true" must be set
  • the HTTPS host must be listed so that the certificate can be acquired (I use LetsEncrypt)
  • the path that You want people to use must be set (in my case

Now whenever someone visits, they will get redirected to without noticing. Their browser will show it accordingly.

Could I help? Buy me a drink ! 💙