I want to manipulate the client url "www.example.com/download.." to "one.other.com/download... But I want that the url on the client maintain the first "www.example.com/download"
Is there any way with Varnish 3 to do this??
I want to manipulate the client url "www.example.com/download.." to "one.other.com/download... But I want that the url on the client maintain the first "www.example.com/download"
Is there any way with Varnish 3 to do this??
Yes, you can easily do it using the regsub()
function in VCL in vcl_recv
.
For instance:
if (req.http.host ~ "^(www\.)?example\.com" && req.url~ "^/download/") {
set req.http.host = "one.other.com";
set req.url = regsub(req.url, "^/download/", "/");
}
This examples rewrites access to http://www.example.com/download/example.jpg
to http://one.other.com/example.jpg
. Of course, it is not visible to the user.