fastly

Varnish: Rewrite a URL if response is 404

一曲冷凌霜 提交于 2020-02-08 04:44:45
问题 I'm curious if there is a way rewrite a URL if response is a 404, in Varnish 2.1.5? For example. I'd like to pull up a URL, which may or may not exist. If the URL doesn't exist, I'd like to do a URL rewrite and try the new URL instead. I'm new to Varnish and don't completely understand the lifecycle of a request (if anyone knows a guy of article explaining this, please share). I've tried setting some variables and request headers, and checking res.status but they seem to get lost someplace in

How to add redirect exceptions using Varnish?

亡梦爱人 提交于 2019-12-13 03:27:28
问题 I am trying to redirect a path e.g. www.something.com/apple/pie to www.something.com/tickets/pie-details but also have some exceptions e.g. www.something.com/apple/helloworld does not get redirected to www.something.com/tickets/helloworld-details This is what I have tried but doesn't work: if (req.url ~ "^/apple/.*" && req.url != "^/apple/helloworld") { set req.url = "^/tickets/.*-details"; error 701 req.url; } 回答1: https://info.varnish-software.com/blog/rewriting-urls-with-varnish