Pages Feature Not Working As Expected

The static hosting or Pages feature (in contrast to the page redirection rules for a given site) aren’t working as expected; true, eventually one finds the option for hiding the pre-release URLs for sites that haven’t yet gone live; but, the problem still remains that it doesn’t represent the same functionality that exists in regular hosting environments, I mean, I used to be able to use an .htaccess rule on the shared hosting provider to basically say: don’t show any page content if the URL doesn’t match my custom URL. Yet, now, a …pages.dev CNAME always resolves to the same website – as it’s not my domain, I can’t use page redirection via cloudflare to control (since the .htaccess rule, something like !^foo (ie: does not match foo) immediately gives an error as there’s no site called that (despite the fact that I was trying to enter a regular expression).

As canonical naming requirements for SEO and for branding purposes require that the exact same content isn’t delivered via different URLs, how and when can this be fixed?

If there is some hidden trick or setting to achieving this, please let me know.

The static website I linked across just uses HTML/CSS and regular image files and does not use a over-complicated framework; but, that doesn’t mean I’m going to jump to using a framework to fix the problem, I think the problem is something that needs to be solved internally as it will affect every user of Pages, since they’ll most likely want the same thing.

Thanks for reading this bug report, and thanks that the Pages integration is relatively painless (I yesterday tested out the competitor in render.com and immediately ran into an infinite loop problem that I reported to them, but that meant I couldn’t get anywhere near as far as this bug report today here at cloudflare, so, it’s progress of a sort!)

Welcome to Pages. It is still newish and they are adding features (slowly). Is what is for now.

You can implement the above using Workers, which is just a bit of javascript.

Ideally though, you should turn off wildcard CNAMEs if this is what you desire. Just foo.domain.com, no *.domain.com.

Thanks, but I think the only sensible workaround in my case (and likely for any other Pages user) is just to add a canonical name to the HTML head section, ie to follow the Google advice here:

Obviously, it would be better if, say, after linking a custom domain for the pages.dev, that the pages.dev resource could then no longer be accessed ‘anonymously’ (ie: without going through the custom domain linked). But, due to the other redirects required for canonical naming, I don’t think it’s possible to do any useful hand-hacking around the removal of the pages.dev name behind the scenes, so for regular users, I think the HTML solution is probably the only possible workaround for the moment.

Thanks,

Russ

That too. On another server you’d have to worry about caching (different URLs cache separately and performance is also an SEO requirement) but that is less a concern on Pages.