Skip to content

Instantly share code, notes, and snippets.

@section-io-gists
Last active April 20, 2021 20:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save section-io-gists/f5e772842947255cd22fce71b762afdf to your computer and use it in GitHub Desktop.
Save section-io-gists/f5e772842947255cd22fce71b762afdf to your computer and use it in GitHub Desktop.
Redirect from bare domain to www site in VCL4.0
sub vcl_recv {
if (req.http.host !~ "www") {
return (synth(850, "Moved Permanently"));
}
}
sub vcl_synth {
if(resp.status == 850) {
set resp.http.Location = "https://www." + req.http.host + req.url;
set resp.status = 301;
return(deliver);
}
}
@localidiot
Copy link

What about removing the www?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment