Custom domain issue with cloudflarepages?

Hi there,

Cloudflare pages generated a subdomain like and i can also use a custom domain like but when a custom domain is assigned why Cloudflare still make site accessible via url i do not want the wesbite to be accessible via after i have assigned a custom domain as both sites can show up on search engines why cant we just destroy to hide the or make it unaacessible after assigning a custom domain?

why this is not the default behaviour thanks

There is no way to completely disable the subdomain, but you have a couple of options to ensure it doesn’t impact your SEO or show up in search engines:

  1. Add something like this to your _headers, to instruct search engines not to index when on the domain:*
	X-Robots-Tag: noindex

For more info: Headers · Cloudflare Pages docs

  1. Or setup Cloudflare Access on your subdomain which puts a login wall in front it: Known issues · Cloudflare Pages docs

ok but instead of me applying hacks to each and every website hosted on Cloudflare pages why Cloudflare doesnt fix this. what is there purpose to keep showing when a custom domain is assigned and it is really not usefull to do when you have multiple website.

the only reason to host on Cloudflare pages is the ease of hosting but if i have to go and apply all the security headers and more advanced fixes then there is no ease of use and it make things more complicated.

does anyone know of any good reason why Cloudflare keep showing site on even after assigning a custom domain?


1 Like

The subdomains can be very useful for developing/previewing on new branches, etc. and _headers is designed for exactly this kind of thing, so I would not consider it a hack whatsoever.

But yes, a way to completely disable it would be useful I imagine, and I know this is something the team is considering for the future. I’d recommend joining the Cloudflare Developers Discord to stay up to date with all things Cloudflare Pages - lots of the team are active there and regularly share what they’re working on. :smiley:

1 Like

i am not comfortable with using headers files and the only reason to use Cloudflare/ Cloudflare pages is so i can easily manage the performance and security without having to deal with techy stuff. Cloudflare can easily make a button to open close developer url for a site instead me custom coding that i can simply click a button to activate or deactive development url while keeping my custom domain live site untouched and accessible at all times.

also there should be an easy security setup for Cloudflare pages since it is a Cloudflare tool and they know what it needs better than i do. :frowning:

If you don’t want to use a _headers file, then you can use the Access setup for now:

Unfortunately there isn’t another solution today, sorry, so I can only recommend following the Pages team and any announcements in future for if this may change.

1 Like

If it was that easy, we’d have done it already trust me haha. Sadly, it isn’t that simple. The _headers file is definitely easiest and @cherryjimbo gave the exact 2 lines you need. You don’t need to do more than that.

Hi @Walshy

Siteground have the option called staging and when i click activate i make the staging url accessible, netlify does similar i dont know what happens in the background but me as a user all i have to do is click active on/off.

Not every one know that assigning custom domain still keeps the url still active i only find out today. also the Cloudflare seucrity could have been made easier for Cloudflare pages as it still ask questions like i am hosting the site somewhere else.

i beleive for your own product to increase the usuability and ease you can add a switch to auto apply fixes that you belive fits better to your product, just saying

thanks @cherryjimbo will try the header code and hopefully i will not make a mess :frowning:

1 Like


Appreciate the feedback. I agree that it would be a good option but I’m just saying, it isn’t a super easy job. Otherwise, it would be added already. Considering we have many alternatives (like _headers, _redirects, Page Rules, Bulk Redirects, Access and more) prioritising the work for this small feature over bigger features with more impact is hard. We’re still a pretty new product, we’ve been around for a year, Netlify has existed since 2014. Trust me, I love Quality of Life work and would love to implement this. It just isn’t something I can knock off in an hour.

It will be supported and we have will have an option in the future. For now, you can use one of the many other options which we have documented.

i mean make the url unaccessible or redirect to the custom domain as otherwise websites show up as duplicate on search engines unless someone write some custom rules. i beleive this should be the default value after adding custom domain. as many will never realize that the website is still accessible on the demo url or if is showing in search results as duplicate :frowning:


hi @cherryjimbo

Cloudflare acess is very dificult and confusing when i follow the instructions it block both .pages and custom domain behind password wall is there a more begginier friendly blog or tutorial with screenshots or video thanks

are there any easy solutions which works and can hide the behind a login screen while not affecting the custom domain the current documentation is either outdated or the functionality is not working as expected

No. A redirect is the best way to not use the right now (as stated above).

Which parts are outdated or do not work? I’m not aware of that being the case anywhere right now. We recently have done a bunch of changes and new additions.

_redirects is text file how can i add the dynamic pages redirects any example wich will not break the custom domain can i add the below example will it work? is there some recomended method for cloudflare pages to custom domain redirect thanks*

+1 on fixing this on Cloudflare side.
Hiding subdomain should be the default behavior when connecting custom domain. This is what vast majority of users would expect.
I believe that many people are unaware of this caveat and don’t even think of searching how to fix it.
Neither the docs nor the UI of connecting custom domain mention it specifically.
It’s something that I concluded from the fact that I was told a cname record is going to be created.

I understand that it’s not a straight forward to fix. This is exactly why Cloudflare should fix it once instead of asking thousands of customers to go through a non-trivial workaround… if they even figured that they should…

For the time being, I’m going to fall-back to Worker-sites.