I’m new to Cloudflare Pages and have moved some sites here form Netlify.
For the life of me I cannot find a way to prevent Cloudflare from removing my page name extensions from URLs.
Is there a way to turn off Pretty URLS (note all of my URL normalisation setting are turned off). I however can’t see where or why my URLs are being transformed.
If anyone has advice I’d be grateful.
There’s no supported way to prevent Pages today from removing the
.html file extension from your pages unfortunately. Any
.html request will be redirected to a version without the extension, such that
example.com/cats.html will be redirected to
Pages is an opinionated platform, but I am hopeful in future that there’ll be some more config and exposed options for this kind of use-case.
Thank you for the reply.
So there’s no way to establish a rewrite rule to bring back the file name extension?
I do not believe so. You may be able to do hacky things like
.html.html, but this isn’t something I’d recommend and I imagine may break at any time.
Another workaround might be using a different file extension like
htm if that works for your use-case.
.html.html does not work. I just tried it and there is actually no way to view the page at all.
.htm actually does work.
I’m from the Pages team, we will have an option for this in the future but what is your use case for having .html rather than the more standard extensionless paths?
Mostly it’s due to legacy sites being transitioned that have rankings in Google and worries that the redirects could impact how pages score. I realise that may not happen and that it could be that all would be fine but rather than dealing with the fallout the preference would be to keep those sites and pages as is.
.htm does work and so does .anything else (.php, .asp, .123), literally anything but .html is stripped.
URLs that have “.” shortens them giving error. For example “www.example.com/team.a.html” , shortens it to “www.example.com/team” removing everything after the (.) failing.
This looks to be working fine for me - https://pages-test-5fz.pages.dev/test.abc (code here: GitHub - Walshy-testing/pages-test)
Could you give an example URL and repo where this is failing?
You are right, now it works. It was a year ago when I got an error in those cases. Thank you
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.