Created
July 15, 2013 23:49
-
-
Save tegansnyder/6004559 to your computer and use it in GitHub Desktop.
Varnish VCL configuration for redirecting non-www traffic to www
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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