Add a query string in a rewrite rule

What is the name of the domain?

placaipva.com.br

What is the issue you’re encountering

I want to write a rewrite rule to add a query parameter like origin=facebook when the ua agent contains “facebook”.

What steps have you taken to resolve the issue?

I’ve created a rewrite rule and I’m able to detect the requests from facebook crawler.
I then want to ADD a query with origin=facebook.
In the Query part of the rule I want to preserve the existing query and just ADD origin=facebook.
The examples I saw were about changing existing params or remove them all.
I want to add the parameter so that I can write a rate limiting rule for those requests that are “fake” facebook crawler with the purpose of scrapping my website.

Thanks

You can use dynamic replace in URL Rewrites:

Something like wildcard_replace(http.request.uri.query, "*", "${1}&origin=facebook") should work.

1 Like

Thanks! @ncano .

It worked!

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