cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Custom clean URL Rules, how does this really work?

r_weber
Pro

I'm struggling with the clean URL rule for services. Haven't found a single working solution apart from using request naming rules (I don't want to use request naming rules if clean url rule feature exists).
Does someone have a clear explanation on how these regexes should look like?

 

From the example given in the UI I'd assume one defines capture groups in the regex and the capture groups would form the "new" url value.

 

Eg if my URL is:

 

/api/v3/domain/products/000840001903

 

and my "clean url regex" is 

 

(.*\/products?\/)[0-9]*(.*)

 

then I'd assume the clean url becomes:

 

/api/v3/domain/products/

 

 (which would be the concatenation of the capture groups?)

 

But instead of that I do get the whole URL replaced with "/"

 

The examples look similar, though all seem to only work for query parameters, not for URL paths.

r_weber_0-1621539071660.png

Documentation with further examples on that feature is also missing and it seems lots of people have the same issue...

 

2 REPLIES 2

andrew_knackste
Dynatrace Helper
Dynatrace Helper

Dynatrace is a bit... Unusual in the way it handles Regexes. In this scenario, it's removing all of the matched text in your regex.

 

Can you try this?

`(?<=\/products\/)\d+(?=\/)`

Hi @andrew_knackste 

This is indeed a bit unusual and not really obvious 🙂 Thanks for sharing! The lookahead match works.

 

I'm just questioning the feature right now as it somehow overlaps with request naming rules and can't even be applied globally or via an API. Also it would be really useful if a "clean url rule" would have options to REPLACE the found string with a custom string like "<productid>" so that the user would know that something has been removed here.

 

This would be especially useful if you have a scenario where you remove multiple parts like: 

/api/v3/CAT-0432A/products/000840001903

 The result of one or multiple clean url rules would be

/api/v3/<category ID>/products/<product ID>/

 

I think I'll add an RFE for that.