Skip to content

Instantly share code, notes, and snippets.

@ricsiga
Last active November 30, 2019 17:46
Show Gist options
  • Save ricsiga/45a7124f9a4d3869852c50fc0e959810 to your computer and use it in GitHub Desktop.
Save ricsiga/45a7124f9a4d3869852c50fc0e959810 to your computer and use it in GitHub Desktop.
redirect in Varnish 4
sub vcl_recv {
if (req.http.host == "www.example.com") {
set req.http.location = "http://example.com" + req.url;
return (synth(750, "Permanently moved"));
}
}
sub vcl_synth {
if (resp.status == 750) {
set resp.http.location = req.http.location;
set resp.status = 301;
return (deliver);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment