Home About Blog

How do I redirect traffic from bare domain to www using Varnish VCL

Custom has asked

How I can redirect all my http://example.com traffic to the http://www.example.com domain. Is there an easy way to do this via VCL?

Here is a Gist in VCL 4.0 that will perform a 301 redirect including the full request path.

This is a Gist for VCL 3