How do I go about automatically redirect any link of the type www.example.com to example.com.
I would like to do this for all link that hits the varnish instance (so i don't have to individually define the value for all domain that hits the server).
I tried using the following:
if(req.http.host ~ "^www\.(.+)$"){
set req.http.host = regsub(req.http.host, "^www\.", "");
}
It works, but the problem with that is it's hitting the right backend, but it's not redirecting. I understand from here: https://www.varnish-cache.org/vmod/redirect you can redirect to a url, but I am not sure how to get the "full" url from varnish to strip out the www and redirect.
Any help would be appreciated!
Thanks a lot!
Jason