Do I still need A records mapped to my naked domain if I've setup page forwarding

So I’ve setup domain forwarding using page rules. I’ve setup 3 page rules (sorry since I’m a new user, system doesn’t allow me to post 3 links):
http(s)://example.com/*
example.com/*

So my question is do I still need A records for my domain example.com? I’ve got a CNAME record for www.

I’m new to domain and DNS so please bear with me.

Could you please explain why you are using page rules to do domain forwarding? Just set a cname record (for @ and www) and you’re done.

Thanks for your quick answer! Well, first of all, I heard you cannot setup cname for your naked domain. Yes I did also hear that cloudflare has special settings to support cname for naked domain but I don’t know how. So it’s simply a cname record that maps @ to www? I will definitely give it a try. Do I still need A records for my naked domain though?

Im not exactly sure what you mean by ‘naked domain’ but if youre simply trying to do domain forwarding then you can make new records for every sub domain you want to forward. in the target field just put your new domain.

Naked domain or sometimes “apex” is what you referred by “@”. I came from godaddy and it doesn’t allow you to setup a CNAME record for @, actually no one else except cloudflare (or maybe there are a few that I don’t know of) allows you to map @ to www. I just mapped @ and removed my page rules. Will check in a few hours see how it goes. I’ve changed settings very frequently the last few hours so don’t know which one is functioning now.

Since cloudflare uses caching and your site actually points to them instead of you, typically if you are only changing DNS settings within cloudflare you can simply purge cache and wait 10 minutes after the change and its usually in effect.

DNS changes on cloudflare don’t have the same ‘wait 48 hours for changes to take effect’ rule that you normally run into using DNS providers.

I presume you want to redirect your naked domain to “www”. Is that correct? If so, check out Redirect example.com to www.example.com

2 Likes

I believe the best solution here is @sandro’s, create both record, even following @Stage4000’s advice of doing a ANAME to the www record (or best yet invert them, put the direct record at the root and then CNAME to the root domain from the www one). A redirect to a single version via a page rule, preferably the HTTPS one of either www or the root, is best for SEO, search engines and users.

If you read OP it is clear that the user was trying to forward an entire domain.

The OP’s question is not very clear but he can hopefully clarify that.

Then your solution is wrong… He needs to basically follow @sandro’s solution, forwarding from the whole domain example.com/* to domain.com/$1 and then www.example.com/* to www.domain.com/$1.

Sorry if my question wasn’t clear. Partially it’s because system doesn’t allow me to post more than 2 urls. So all I want is to forward example.com, without prefix of http/https, with http, or with https, all to https://www.example.com.

The solution I’m currently taking is in 2 steps.

  1. Following @Stage4000’s suggestion, I created a CNAME record to map my naked domain to www.
  2. However, it looks like the CNAME record doesn’t take care of https://example.com -> https://www.example.com. Therefore, I created a page rule https://example.com/* -> https://www.example.com/$1.

I’ve read @sandro’s tutorial and it’s suggesting using purely page rule to do the forwarding and that’s what I did originally. However, it seems I would need 3 page rules in my cause to cover my 3 cases and with Stage4000’s suggestion, I ended up with one CNAME and one page rule. I didn’t setup any A records to point my naked domain to any static IP and it seems still working. Is any drawback with my current config?

You dont need any CNAMEs. All you need is one page rule, just follow the tutorial. There is a reason why it is there :wink:

Thanks @sandro. I was worrying that example.com/* would not match http(s)://example.com and I would have to use \*example.com/\*. But if I do that, it would incorrectly forward my sub domains such as staging.example.com to https://www.example.com, which is not what I want. If example.com/* can do the job it’s ideal. But if example.com matches https://example.com, wouldn’t it match staging.example.com too? Could you clarify?

It does match it. Seriously, just follow the tutorial step by step. @domjh put a lot of effort into these.

All you need is one single page rule and a dummy A record for your naked domain. Thats it.

1 Like

@sandro sorry if my questions bother you but as a programmer, I not only want to know how but also would like to know why, if possible.

Why what exactly?

If example.com/* matches https://example.com, why doesn’t it match staging.example.com? If it matches, then that’s not what I want.

It doesnt match it because you dont have a wildcard configured, hence it will only match the hostname you specified and that is what you want.