How to set the domain for CloudFlare so it won't direct the prefix of www

cdn

#1

G-d willing

Hello,
I am having a WordPress website which is using an SSL certificate.
The website is configured not to use the www prefix and it is https://domain-name.com.
Currently, the CDN is directed to https://www.domain-name.com. So how can I configure the CDN to work with the non www address.
The website is hosted with SiteGround and I am using the free CDN package.

Thanks,


#2

The easiest way would be not to configure a DNS record for www. Alternatively you can also use a page rule to redirect to the naked domain.


#3

First, thank you very much for your response.
And how do I do what you said?
How do I remove the configuration for the DNS record of www?
Also, how can I set a page rule to redirect the naked domain? Is it thru WordPress…?

Thanks again for the answer.


#4

You open the DNS settings in your Cloudflare control panel and delete the respective record.

But keep in mind, in this way your site wont be reachable under www. If you still want it reachable you set up a a page rule. Have a look at Cloudflare’s help centre for a detailed walkthrough.


#5

G-d willing

Thanks again for the answer.
It is really helping me.
I do have a question about the page rule I need to create.
I must say that I am totally new to all this CDN thing and also (of course) to these page rules.
I read this support page: https://support.cloudflare.com/hc/en-us/articles/218411427
And want to do a redirect as I was advised.
So for the first field “If the URL matches” I typed:

www.domain-name.com/*

I typed the asterisk sign before and after the value - just the post here does not show it since it is the shortcode for “Bold”
As for the rule settings I choose:

“Forwarding URL”

And for the destination URL, I typed:

domain-name.com/*
Also here, I typed the asterisk sign before and after the value - just the post here does not show it since it is the shortcode for “Bold”

Is it okay?


#6

The match seems to be alright, however for the destination you’d like https://domain/$1


#7

G-d bless you for the rapid response.
thank you very much my friend.
I am setting the rule as permanent, right?
I don’t see a reason why it be temporary.

Thanks again!


#8

If it is unlikely you ever want to use www you can do that. Otherwise temporary might be possibly better as it can be sometimes tricky to get “rid” of a permanent redirect as they are typically cached and it can take some while for that to expire.


#9

Thank you very much my friend.
I really appreciate it.
Currently I set it to permanent. Hope it will do the job well.


#10

I have just noticed that no matter what I type after the domain name, it is always returning the domain name only without the rest.
For example if I want to go to the “www.domain-name.com/contact-us” I am being redirected to “https://domain-name.com” only without the contact us.
How can I fix this?
I have uploaded a screenshot of how the rule looks like.


#11

Thats because you have two asterisks. Remove the first and $1 should match.


#12

I am sorry but I didn’t get you on this one.


#13

Simply remove the * in front of www :slight_smile:


#14

Thank you very much, it is working now.
G-d bless you for the help