There’s an SEO issue where we have duplicate domains ..
For example – www.domain.com and domain.com.
I would like to recreate a 301 redirect from the apex website (www.domain.com) to the non-apex URL (domain.com)
Our UI application is hosted on GCP/GKE. I have found annotations for nginx type ingress to create such redirect .. but in our case, we’re using GCP native ingress instead.
Any help or documentation will be highly appreciated. Nothing I found currently suits my needs.
2
Answers
I was able to configure the apex to non apex redirect using the following YAML configuration
Saving the file as
redirect.yaml
, and then apply usinggcloud compute url-maps import global-lb-map --source .redirect.yaml --global
'target-https-proxies' and 'forwarding-rules' resources have to be configured aswell.
the following commands may be used
target-https-proxies
forwarding-rules
When all 3 have been configured, make sure you remove the apex domain from your ingress configuration field and create an A type DNS record pointing the APEX to the newly created static IP that was assigned with your load balancer.
You will then be able to see the redirect succeed.
Thanks @JanMaroon for your help.
I think this documentation will help you in this case.
(https://cloud.google.com/load-balancing/docs/https/setting-up-global-traffic-mgmt#configure_a_url_redirect)