Www to non-www redirect (cloudflare rules or .htaccess). which one?

I want to redirect non-www url when visit with www

There is two ways to do it. with .htaccess and cloudflare rules.

Just want to know, which one is good? or both is ok

or I have to do it in both cloudflare rules and .htaccess too

If your site is proxied, and always will be, you can just do it in Cloudflare. The redirect will be returned from a Cloudflare PoP so is much faster than Cloudflare passing the request to your server to redirect (and means fewer requests to your origin as well).

If the DNS record is not proxied, or anyone accesses the server without using Cloudflare, then you’ll need the redirect on the server.

You can do both, if Cloudflare can redirect it’s faster, if the request doesn’t pass through Cloudflare then your server can do it instead so that’s the safest way.


thank you.

And I am seeing “Page rule” redirect is depricated.

Can you tell me how to do it with “Redirect Rules” ? or Just give me how-to guide link.

There is a migration guide here…

…or a tutorial here…


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