Workers Site: How to redirect non-www to www?

Title pretty much says it:

I have a Worker site & want to redirect non-www traffic to www

Using Page Rules doesnt work (I assume as the Worker is deployed before the Page Rule takes effect?)

Any other way to implement this?

This is the Page Rule I currently have:

I do my redirects on the Origin Server.
Other page rules works without any problems here.
Not sure why it not works on your side !

Did you try the full URL for Matching
in this case*

You need replace with your own domain !

A page rule matches a URL pattern based on the following format (comprised of four segments):


An example URL with these four segments looks like:

The scheme and port segments are optional. If omitted, scheme matches both http:// and https:// protocols. If no port is specified, the rule will match all ports.

Finally, you can disable a page rule at any time. While a rule is disabled, actions won’t trigger but the rule still appears in the Page Rules app, is editable, and counts against the number of rules allowed for your domain. The Save as Draft option creates a page rule that is disabled by default.
See for more Information about Page Rules URLs

Maybe you have found allready this Step by Step Tutorial that should help you !

The example they give it literally exactly the same as the image I posted (except mine is permanent)

CF example image:

My example image:

I copied exactly the examples they give in the tutorials, but it doesnt work.

Remember I do not have an Origin Server, this is a Worker site, there is no server it is just html code.

I will try adding https:// to the url to be redirected to see if that makes any difference.

Tried adding https to the non-www url to be redirected and it still fails.

I guess it has to be because Workers are deployed before Page Rules?

But copying the exact what is in the picture will not do it !

As said you need replace with your own domain
like instead

Try the Example but with your own domain and it has to work !

I know that lol, I have many regular websites on CF this is the first Worker site I am deploying publicly

Yea it doesnt work

I can get it to work in the other direction.

ie going from www to non-www Page Rule redirect works.

But going from non-www to www doesn’t


Found out what was the problem. an extra dot was needed in my worker as described in this post:

Marking this as the solution

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