No subpath matching in single redirect rule

I need to preserve the subpath when redirecting my URL…

For example I want to redirect to but preserving, subpaths so that: maps to

There is a suitable option in the Bulk Redirects for this (when creating a list item):


But nothing in the Single Redirects (only choice is “Preserve query string”):


Sure, I can use the bulk feature for this but I don’t have that many redirects to justify use of the “bulk” feature (seems like overkill, and it’s more hidden away with more steps to get to the list and view/edit it)… plus, the inconsistency is just annoying!

Also, and I know it’s a beta feature so is not finished, but it seems like a big oversight that once you create a rule within a bulk list, you cannot edit it (or even see what sub-options are set for it, like subpath matching, whether it’s a 302 or 301 redirect etc)… only option is to delete a rule :-/

Use concat. :point_down:t3:

@sdayman except that in my case I can’t just use the entire path… I’m not forwarding all requests, only those sent to /getData, and so I need to replicate only what comes after that.

Frustrating thing is that in a Page Rule you can use *and then $1 to grab what you want, but in a single Redirect Rule you can’t, and also don’t have access to subpath matching like you have in Bulk Redirect.

It all seems very inconsistent and messy.

I’m not seeing the difference. Your example is just changing the hostname. Then both have the same path beginning “getData”, and you want to preserve the rest. That’s the same path.

OK you’re right. But I can’t see any option to edit the Expression for the destination, only the source:

Do you just put the expression directly into the URL field, like above?

“Edit Expression” is for the “When incoming requests match…” It’s only necessary for complex matches that you can’t accomplish with the Expression Builder.

I’d change the Match to check hostname, and then Path Starts:

Yes, the destination is edited in the URL box. Be sure to set “Type” to Dynamic (not Static).

Thanks. I like the idea of splitting that incoming part of the rule into hostname and path, because it corresponds more closely in my head to the way in which the destination is pieced together.

For some reason I’m too afraid to use a 301 redirect rather than a 302 but maybe one day I’ll brave it!

1 Like

And thanks for the intro to custom Expressions… I very soon moved into using the Expression editor for the incoming part of the rule too, to cover multiple sub-paths:

( eq ""
  (starts_with(http.request.uri.path, "/getData") or starts_with(http.request.uri.path, "/getProgress"))

So far as I could see, the expression builder doesn’t support A and (B or C)… only a sequential A and B or C which is actually (A and B) or C?

1 Like

Right, which is probably the first reason people will go into the Expression Editor.

1 Like

Sure. I’d far rather use regexp for advanced matching and replacing… Could combine rules even further… But I think that’s a paid feature.

e.g. I want to redirect firstgetter and secondgetter to firstlookup and secondlookup (for multiple sub paths), i.e differing in only the first part, which would be easy with a single regexp.