CF and "non www" addresses. Is it possible?


#1

Hi,

I have a Siteground hosting. Siteground is Cloudfare’s partner, so I could activate it quickly.

My current website is configured to have “non www” address as main address --> (mysite.com instead of
www.mysite.com), but I read that CF works only with “www” addresses.

That means that using “non www” address it will use the normal server, while “www address” will use CF.

Questions:

  1. Is it true?
  2. Is there any chance to configure CF in order to use “non www” address as main instead of www?
    2b) If so, is it possible with the free plan?

Thank you very much,

A.


#2

• Completely not true.
• It’s up to your DNS settings in Cloudflare. Point the domain to your server’s IP address and you can serve the naked domain name.
• Yes, works in the free plan.


#3

To add onto Jules’ response, you can do all this…if you use a direct Cloudflare setup. Some hosting partners set up CNAMEs in order to leverage Cloudflare, and this seems to interfere with a non-Cloudflare “non www” address. It could be that Siteground is correct that it needs to access your site with “www”. There’s a bit about CNAME flattening at root here:


#4

Hi guys, thanks for your answer.
I suppose that sdayman is right. Since everything will/would be automatic with Siteground (and I’d like to follow this automatic path), it is possible that “non www” could not with CF.

If so, do you think that touching aftwerwards manually the server configuration from CF, as jules said, would fix the issue? (I am quite new to this kind of things, sorry)


#5

I manually moved my DNS from SiteGround to CloudFlare and facing issues that are somewhat related to OP’s questions.

First, I did:

  1. Assigned a CNAME to ‘www’ with value ‘mydomain.com’.
  2. Implemented a 302 forwarding from ‘www’ version to ‘mydomain.com’ using Page Rules.

When checked, the www url is getting forwarded to the naked domain, but is retaining the www prefix! (Like how url masking is done.)

Anyone got some idea, what happening?!


#6

That doesn’t make sense. It’s forwarding, but still has the ‘www’? That doesn’t sound like it’s forwarding.

I like your approach of using a Page Rule to forward to the naked domain, but the ‘www’ should go away when you redirect to the naked domain.


#7

Accessing the www url in Browser was showing the prefix but Pingdom test showed the subdomain was being 302 redirected to naked domain.

Anyways, the issue got resolved by itself! Appears to be an caching/propagation issue. :slight_smile:


#8

Hi again,

First of all, I am newbie in this kind of things, but I got that CF will speed up a lot my site. I want to use it.

My first idea was to use the easy 1-click solution from Siteground, but after your answers and googling a bit, I figured out that the only effective way to use the NAKED domain is using the manual configuration.

That will avoid me possible SEO-related issues due the need of “www” in order to use the easy 1-click Siteground configuration.

Question: Is it complicated to set up and configure, from scratch, all the things directly from CloudFlare? (instead of using 1-click SiteGround solution)

Thanks for your help…


#9

It’s pretty easy. If you have your site up and running on Siteground, without their 1-click solution, Cloudflare does most of the work for you. Once you tell Cloudflare you want to add your domain, it will scan your DNS, then tell you how to set your domain to use Cloudflare.


#10

@andygrat, I would rather suggest to try 1-click Siteground solution first. When you add CloudFlare from within Siteground control panel, CloudFlare will fetch all DNS records of your domain and subdomains on it. Whereas, when you manually configure, CloudFlare fetches DNS records externally and may sometimes miss DNS records of the subdomains and you may have to add them separately.

Anyways, once the domain has been added to CloudFlare…DNS records fetched… and the Nameservers at your Domain Registrar updated with your CloudFlare Nameservers you’ll configure as follows for www to non-www redirection:

As STEP 1, ensure that the naked domain is pointing to your SIteGround IP using an A record. It would look like this under CloudFlare DNS section:

[A] [mydomain.com] [points to 146.66.64.23] [Automatic] [Orange Cloud]

… and the www subdomain be CNAMEd to Naked domain:

[CNAME] [www] [is an alias of mydomain.com] [Automatic] [Orange Cloud]

As STEP 2, you would use the following Page Rule under Page Rules section for redirection:

If Url matches: http://www.mydomain.com/*
Forwarding URL with 302 Redirect
to http://mydomain.com/$1

That’s all! Hope this clarifies.

Or, you could hire someone to do the stuff for you https://www.fiverr.com/search/gigs?query=cloudflare


#11

Hi guys:

@sdayman thank you, it looks quite easy even without having a great knowledge. Do you recommend to do it directly from CF, or just “tweaking” CF after the 1-click Siteground solution, as hemachandar did?

@hemachandar It seems a straightforward procedure and it looks interesting to me, but I have some questions for you since you have passed through the same path:

  1. why did you choose to use 302 instead of 301, if you want to use this redireccion permanently?
  2. are you figuring out some issue using all this setup?

For both hemachandar and sdayman:

  1. If I try the hemachandar solution, and I find problems, could I revert everything and try once again from scratch from CF directly?

4)…the very last thing, I promise… SG has Railgun support. As per their FAQ: “Railgun: accelerates the connection between Cloudflare and the SiteGround server. It uses web performance optimization technology to increase considerably the delivery speed of uncacheable dynamic and personalized content. To take advantage of it you need to switch it ON.” ----------------------------> If I decide to try 1click solution + manual tweak in CF, this railgun support will work also on my naked domain, since it will be a separate rule only present in CF?

thanks a lot guys, your help is really really precious!


#12

Ok, to answers your questions…

  1. why did you choose to use 302 instead of 301, if you want to use this redireccion permanently?
    – The site is still in nascent stages of development and we aren’t really sure whether to go with www or non-www version. It is easier to switch an 302 redirect instead of 301. Further, I’m yet to know which redirect is better from the perspective of SEO and we will change the page rule to 301 if it is to be preferred.

  2. are you figuring out some issue using all this setup?
    – No particular issue. Just trying to make the site production ready.

  3. If I try the hemachandar solution, and I find problems, could I revert everything and try once again from scratch from CF directly?
    – Apparently, yes. You can remove the domain added through hosting partner https://support.cloudflare.com/hc/en-us/articles/200167916-How-do-I-remove-a-domain-that-I-signed-up-through-a-hosting-partner- and then add it anew from Cloudflare dashboard.

  4. If I decide to try 1click solution + manual tweak in CF, this railgun support will work also on my naked domain, since it will be a separate rule only present in CF?
    – Unfortunately, not familiar with Railgun setup. All I can say is something does wrong the CF/Railgun setup, it is completely reversible and can revert to the present state - just make sure to note down/screenshot/backup any data/record/setting changes you would be making while making the setup.

Cheers!


#13

This is not overly complex.

Create a Page Rule for mydomain.com

url matches - * www.mydomain.com/ *

then forward (301 or 302)

http://mydomain.com/$1

NB the star symbol above is because CF markdown, put them exactly before and after the url match (no space)


#14

This topic was automatically closed after 14 days. New replies are no longer allowed.