0

I am trying to redirect a path e.g. www.something.com/apple/pie to www.something.com/tickets/pie-details

This is what I have tried but doesn't work:

if (req.url ~ "^/apple/.*") {
    set req.url = "^/tickets/.*-details";
    error 701 req.url;
}

Am I missing something?

James Z
  • 12,209
  • 10
  • 24
  • 44
Raymond Ly
  • 42
  • 4

1 Answers1

0

You either need to capture the matches from the regex, or if it is simple just replace using regsub()

However I have read that these are no longer bundled in core varnish so you might need a vmod. This one appears to be the one you need: https://gitlab.com/uplex/varnish/libvmod-re

Here are some docs on how this can be used: https://docs.fastly.com/en/guides/vcl-regular-expression-cheat-sheet#capturing-matches

Basically the re object lets you use the matched portion to then assemble the new url using string operations.

All of the above is speculative using my knowledge of vcl and regex, but I personally have not tried it.

MattWhiteley
  • 176
  • 6