Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tegansnyder/6004559 to your computer and use it in GitHub Desktop.
Save tegansnyder/6004559 to your computer and use it in GitHub Desktop.
Varnish VCL configuration for redirecting non-www traffic to www
# added this to
sub vcl_recv {
if (req.http.host == "yourdomain.com") {
set req.http.Location = "http://www.yourdomain.com" + req.url;
error 750 "Permanently moved";
}
}
# add this to vcl_error
sub vcl_error {
if (obj.status == 750) {
set obj.http.location = req.http.Location;
set obj.status = 301;
return (deliver);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment