WWW to Naked Domain with Redirect Rules, preserving Path
Hey all, here's a kind of dumb one, but I'm looking for help with Redirect Rules (single rule).
The structure I'm looking for is, when incoming requests match:
URI Full starts with https://www.domain.com
or
URI Full starts with http://www.domain.com
Then URL redirect to
(effectively) https://domain.com/$path
I tried static with Preserve Query String, but it doesn't look like that's path aware, just query aware.
I think I need a dynamic expression, but I can't find any documentation for that use case and I searched a few pages of discord and same.
The page rule I'm trying to replace was redirect from www.domain.com/* to http://domain.com/$1
Thoughts on the expression I should use?
Thanks!
Website Domain Names, Online Stores & Hosting - Domain.com
Finding the perfect website domain is as easy as 1-2-3. Buy a domain name, build and host a website, and enjoy our professional online marketing tools.
Website Domain Names, Online Stores & Hosting - Domain.com
Finding the perfect website domain is as easy as 1-2-3. Buy a domain name, build and host a website, and enjoy our professional online marketing tools.
3 Replies
Bulk redirects are easier for this, but you can use redirect rules as well
It's easier to use
Hostname
eq
www.domain.com
for match, and you can use the dynamic expression concat("https://domain.com", http.request.uri.path)
to keep path@chaika.me exactly what I was looking for. Thank you!
Bulk Redirects is officially the right way https://developers.cloudflare.com/pages/how-to/www-redirect/
Redirecting www to domain apex · Cloudflare Pages docs
In this guide, you will learn how to redirect the www subdomain to your apex domain (example.com). This is a common question and can be achieved by …