Rewrite rules don't work

Hi guys, I’m creating a Rewrite Rule and it doesn’t work, does anyone know what I did wrong?
I want to rewrite the URL for all iPhone users to: site .com/?iPhone=1

How did you establish that this does not work?

Sorry for not explaining this earlier.

I think I set it to check all UserAgent, if it contains the word “iPhone” then it should redirect to the same address with the query: “?iPhone=1”

And when that doesn’t happen I think it doesn’t work.

It is a rewrite, not a redirect. So the feature works as intended, you are just not using the right feature :slight_smile:

You will need page rules instead, however there you can’t check for the user agent. The rewrite should actually work fine, why do you need a redirect?

I still don’t understand so what exactly this rule does, Sorry.

For Cache issue, I would like to offer different cache for iPhone/iPod, Android, iPad/Tablets

So this is not possible with Cloudflare?

I’d suggest to read up on the documentation in that case.

But the rewrite rule should actually run before the cache, so I’d assume that should work. Otherwise it’s probably best send the redirect directly on your server. You can certainly also use Workers and even a combination of rewrite and page rules may work, but I’d still simply configure this on the server.

I’m confused, the rewrite rule doesn’t show up in the client url, right?

But it delivers the page differently, as if it were accessing ?iPhone=1, but masked, right?

It also serves to determine the language displayed by the site, right?

If in all users in Brazil, I add the “?lang=pt” this query will not appear for the client, but it will present the content in “Portuguese”

That’s it?

Precisely, it will be sent to the server.

As for what content it shows, that’s fully up to your server. Currently you are setting the query string to that value and that should be also what’s used for the cache.

I understood!

I was expecting an answer on the client, but on the server it’s better than I expected, I’ll test and reply here soon, thanks for the help!

It was exactly what I needed, the Server and CF Edge deliver a different page depending on the UserAgent.


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