Cloudflare Dynamic Redirect - redirect

I want to redirect a url appended with a query string
for example:
example.com/page?=r123) to example.com/page
So the request expression is:
(starts_with(http.request.uri.query, "r="))
Then my redirect expression should be what?
Thanks for reading

Related

Redirect ALL get parameters to another domain in Nginx

Only answers I can find for this have specific parameters and don't work if the parameters change.
I have a URL coming in such as:
/logs.php?user_id=10032&account_id=10099&message=0&interval=1&online=1&rsid=65374826&action=update&ids=827,9210,82930&session_id=1211546313-1602275138
I need to redirect this url to a completely different domain and file but keep the get params.
So it ends up redirecting to:
https://example.com/the_logger.php?REPEAT_ALL_GET_PARAMETERS_HERE
Here is what I have unsuccessfully tried so far:
location logs.php
{
rewrite https://example.com/the_logger.php?$args last;
}
But it doesn't seem to match the url or redirect. I think I'm misunderstanding the logic of nginx confs. If it were .htaccess I think I'd be okay. I can put a few more examples here if need be of what I'm trying to achieve.
As you state this is a redirect and not reverse proxying a request, I would use the return directive to tell the client to do a 301 or 302. Using the return directive is the simpler and more recommend approach to redirecting a client.
Something like should do what you want:
location /logs {
return 302 https://example.com/the_logger.php$is_args$args;
}
Where $is_args would output a ? if and only if the query string is not empty, and $args is the query string itself

JMeter redirection URL

I'm trying to stress test a website where people are able to create reports which are stored in SQL, etc...
Let's say the page orders are the followings:
mywebsite.com/home
mywebsite.com/reports
mywebsite.com/reports/create
mywebsite.com/reports/2
As you can see, there is a sub-page called reports. It has a create button. Then the user is being redirected to the create sub-page. When it clicks the save button, it get's redirected straight to its reports sub-page. Now my issue is I don't see the redirection URL that is being received by the browser where to be redirected. Maybe the report ID will be 3 or 4, or 123.... etc. I want this value as a variable. At the create sub-page I have a Response code: 302 but I can't figure out where is it redirecting the user to and where can I modify this URL value.
When you are being redirected the server sends Location header which indicates where exactly you are being redirected
In order to extract this redirect URL you can add Regular Expression Extractor postprocessor as a child of the main request and configure it like:
Apply to: Main sample and sub-samples
Field to check: Response headers
Reference Name: anything meaningful, i.e. location
Regular Expression: Location: (.*)
Template: $1$
Assuming everything goes well you should be able to refer the extracted value as ${location} where required.
References:
Using RegEx (Regular Expression Extractor) with JMeter
JMeter: Regular Expressions

Nginx URL rewrite storing part of URI & Using it in redirect

Trying to make a nginx url rewrite for a branding only global site that
has search functionality (but no product catalog assigned as it's the global site) that will store part(or all if it's better) of the URL to pass it to a dedicated redirect script that geo redirects the user's query to the correct regional site.
Can someone tell me what is wrong with what I am doing?
rewrite ^/catalogsearch/result?q=(.*)$
/redirect-script?x=/catalogsearch/result=q=$1
permanent;
I don't think you can match the query string with the rewrite regexp.
Try this:
rewrite ^/catalogsearch/result$
/redirect-script?x=/catalogsearch/result=q=$arg_q
permanent;
$arg_q is one of the automatic variables containing the query arguments, see http://nginx.org/en/docs/http/ngx_http_core_module.html#var_arg_

How i can redirect an url with query string to the url without query string in NgInX?

I need to redirect/rewrite an url that contains query string to the same url, but without query string. For example http://domain.com/a-post-title/?fbid=xyz to http://domain.com/a-post-title/
Sorry for my bad english.
Easy, just put a ? at the end of your rewrite,
from http://nginx.org/en/docs/http/ngx_http_rewrite_module.html#rewrite:
If a replacement string includes the new request arguments, the previous request
arguments are appended after them. If this is undesired, putting a question mark at the
end of a replacement string avoids having them appended

Redirect to URL using Regular Expressions in Fiddler

How to Redirect to URL using Regular Expressions in Fiddler?
If URL mathes
regex:(?insx)^http://www.(.*)$
respond to
http://proxy.exampleproxy.info/?u=(???? what wtite here ???)
You can use AutoResponder tab to provide regex with groups as match rule and use substitution syntax in action string.
For example write this in match rule input:
regex:(?isx).*\.mycdn\.net\/.+\.(jpg|png)\?w=(\d+)&h=(\d+) #matching image urls from cdn
and this in action string input:
*redir:http://lorempixel.com/$2/$3/cats
this rule will match url like this:
http://someimage.mycdn.net/some-directory/some-url.jpg?w=300&h=166
and would redirect to this url
http://lorempixel.com/300/166/cats/
*redir action means that fiddler would respond with 307 code (Temporary Redirect) and Location header with url to redirect. If you omit this string then fiddler would respond with 301 code (Moved Permanently) instead.
fiddler2 doesn't support using the capture text in the response.
http://groups.google.com/group/httpfiddler/msg/60e8b897867cdb7b
Need to use rules instead.