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/e6c46bde97147e6ae7d1ff9989c7781a to your computer and use it in GitHub Desktop.
Save section-io-gists/e6c46bde97147e6ae7d1ff9989c7781a to your computer and use it in GitHub Desktop.
Redirect from bare domain to www site in VCL3
sub vcl_recv {
if (req.http.host !~ "www") {
error 850 "Moved Permanently";
}
}
sub vcl_error {
if(obj.status == 850) {
set obj.http.Location = "https://www." + req.http.host + req.url;
set obj.status = 301;
return(deliver);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment