Redirect an url with params


#1

Hey guys, i’m new here, and i’m trying to redirect a feature in my website. It’s a running web page when the runners share their results with other runners.

The page to share the results is e.g.:
www.diariodecorredor.com.br/[email protected]

It’s redirects to www.diariodecorredor.com.br/[email protected] by .htaccess .

But my server start to block this requisition claiming to be attempted invasion. I can change this for another url, like www.diariodecorredor.com.br/[email protected] or www.diariodecorredor.com.br/[email protected] , but the first is better to share.

So i’m trying to redirect this in cloudflare without results. I try:

Rule:
https://www.diariodecorredor.com.br/@

Redirects to:
https://www.diariodecorredor.com.br/[email protected]$2


#2

That might be WAF. Do you have that enabled? If so, try disabling it

As for your page rule, it probably does not work as the pattern also matches the redirection URL and so probably goes in circles.


#3

I presume you get the following error

image

The details would be

Forwarding URL matches the target and would cause a redirect loop

in this case.


#4

I believe the rule you meant to ask would be:

Rule
www.diariodecorredor.com.br/*@*

(No need to specify https, but need to create two capture groups, which in Cloudflare are just the * character, that would then be transported in $1 and $2 respectively.)

However, as @sandro has pointed out, this rule results in an error, as I believe Cloudflare would not accept the special character @.

You could set the rule with the @ encoded as %40, but this would only work if you could control how the URL is input, which is not the case.

If everything worked fine, you then would face the issue of a loop, as the expression

/[email protected] would also match your rule.

I believe you’d be better off avoiding the CF page rule redirect altogether, and just create the redirect at the server level using a regular expression that can stop the redirect when it finds “filter.php”.


#5

From what I understood, it is not so much the at symbol but the resulting redirection loop which is the issue. This could be prevented with aforementioned second page rule but the check does not take other page rules into account.


#6

Oh, I see… Then it’s possible to create the following rule:

…and have the filter.php handle the decoding of the URL!


#7

Maybe :), would need to test it before I make wild promises :woozy_face:


#8

I tested this rule on my testing website with Chrome and Firefox and it did work as far as redirecting goes. Of course @andersonbravo would have to test it in his environment, and also take steps to make sure other issues won’t make this a bad experience for the user. I’m thinking browsers that send the already encoded URL request, which could result in a 404.

Also: if the website generates other, unrelated URLs that happen to contain an email address, they will be wrongly redirected to /[email protected], so definitely this need to be done carefully.


#9

@floripare, you might be onto something.

Still testing.


#10

Aforementioned approach with the initial stopping page rule coupled with the URL encoded at symbol (to trick Cloudflare’s parser) should actually work


#11

The ?q should be ?r.


#12

And in my posts, /filter.php should be /perfil.php :slight_smile:


#13

https://www.diariodecorredor.com.br/’@’


#14

Not sure what you meant with your last response.


#15

It’s work, but staying in looping when i click in a link in the page =/


#16

Hey man, it works !! =] very thanks


#17

Can you post a screenshot of your rules? The way I posted it should work.


#18

Thank you guys. it’s work!rule2


#19

All right, excellent!

And credit where credit is due, @floripare made a very point about the URL encoded character, otherwise we’d be still fighthing the rule parser and its conviction of a redirect (which is actually not wrong, if it werent for the first rule).


#20

Oh no =[ my friend, the rule Geolocation worked in first time, but now stop … and i started a looping

You can see in the url http://www.diariodecorredor.com.br/[email protected] , and then there is a link ‘[ Detalhar ]’

The url redirect to https://www.diariodecorredor.com.br/perfil.php?email=eu%40andersonbravo.com.br and then to https://www.diariodecorredor.com.br/perfil.php?email=perfil.php?email=eu%40andersonbravo.com.br&det repeating the ‘perfil.php’