Redirect http, www, and .io to one main domain

What is the name of the domain?

iulianonofrei.com

What is the issue you’re encountering

Too many redirects

What are the steps to reproduce the issue?

I’m struggling for the past half hour to post this, because, stupidly enough, the forum for domain-related questions doesn’t allow new users to post 4 links, even if they’re enclosed as code blocks.

I followed both Redirecting www to domain apex · Cloudflare Pages docs and Redirect one domain to another · Cloudflare Fundamentals docs, but…

www.iulianonofrei.io doesn’t work, and iulianonofrei.com has too many redirects.

I want to:

  • “disable” http by always redirecting to https,
  • “disable” www by always redirecting to the apex domain,
  • have a “shortcut” of iulianonofrei.io for iulianonofrei.com.

This means that any combination like http://www.iulianonofrei.io, https://iulianonofrei.io, https://www.iulianonofrei.com should redirect to https://iulianonofrei.com.

For future-proofing, it would be nice if paths and query params are also supported (and correctly transferred during the redirect).

From all the DNS and redirect (single, bulk, etc.) options available to us, what would be the most idiomatic and correct way to achieve this?

Check your SSL/TLS setting is set to “Full (strict)” in your dashboard here…
https://dash.cloudflare.com/?to=/:account/:zone/ssl-tls

Enable “Always use HTTPS”…

See…

Create a Redirect Rule in the same way as above.

2 Likes

Check your SSL/TLS setting is set to “Full (strict)” in your dashboard here…
https://dash.cloudflare.com/?to=/:account/:zone/ssl-tls

It was set to “Automatic”, as I thought that the website knows better than me, and that it enforces https with it.

I changed it to “Full (strict)” for both domains.

Enable “Always use HTTPS”…

I confirm that it was active for both domains.

See…

Before setting up this AAAA DNS rule, should I delete the A DNS rule pointing to 192.0.2.1?

Create a Redirect Rule in the same way as above.

So, with the hostname condition of iulianonofrei.io instead of www.example.com, and with the expression concat("https://iulianonofrei.com", http.request.uri.path) instead of concat("https://example.com", http.request.uri.path)?

You can use either.

Yes, you might want to also include www.iulianonofrei.io as well by using hostname is in.

1 Like

And I also need an AAAA DNS record for the root, besides www, right?

I just noticed that, for another domain, I have a CNAME DNS record from www to revolter.github.io.

So maybe the fact that these domains point to content hosted on GitHub causes all these issues, and I should use CNAME instead of AAAA & redirect rules?

It’s up to you, but if you CNAME a hostname to a host make sure that each hostname is configured as a custom domain on that service.

Usually for SEO and consistent analytics, people want a single hostname to be active (say www.example.com) and everything else to redirect to it (example.com, example.org, www.example.org, etc).

1 Like

Yes, you might want to also include www.iulianonofrei.io as well by using hostname is in .

In the end, I decided to keep them separate:

  • a rule for specifically redirecting www to the secondary root, and
  • another rule for redirecting the secondary root to the main domain.
1 Like

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