Dynamic Redirect to redirect all requests except ones specified

I am trying to use the new Dynamic Redirect feature to build an expression that says if the request does not exact match/contain the URL path (including root domain) it should redirect to root domain.

However, it ends up in a redirect loop. Here’s an example of my expression:

(not http.request.uri.path contains "/app/") or (http.request.full_uri ne "https://example.com/how/") or (http.request.full_uri ne "https://example.com/faq/") or (http.request.full_uri ne "https://example.com/fees/") or (http.request.full_uri ne "https://example.com/token/") or (http.request.full_uri ne "https://example.com/about/") or (http.request.full_uri ne "https://example.com/report/") or (http.request.full_uri ne "https://example.com/contact/") or (http.request.full_uri ne "https://example.com/aup/") or (http.request.full_uri ne "https://example.com/cookies/") or (http.request.full_uri ne "https://example.com/terms/") or (http.request.full_uri ne "https://example.com/privacy/") or (not http.request.uri.path contains "/js/") or (not http.request.uri.path contains "/css/") or (not http.request.uri.path contains "/images/" and http.request.uri.path ne "/")

EDIT: Sorry not sure why it doesn’t soft wrap even though I know it’s a single line

Any idea how I can get it to work so that all URLs except the ones listed in the expression and including root domain are redirected to the root domain? Thanks!

I’d assume this should do the trick.

not http.request.uri.path in {"/" "/about/" "/aup/" "/contact/" "/cookies/" "/faq/" "/fees/" "/how/" "/privacy/" "/report/" "/terms/" "/token/"}
and not http.request.uri.path contains "/app/"
and not http.request.uri.path contains "/css/"
and not http.request.uri.path contains "/images/"
and not http.request.uri.path contains "/js/"
3 Likes

Winner! Thank you so very much :smiley:

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.