Akira Kurogane
CDCloudflare Developers
•Created by Akira Kurogane on 4/4/2025 in #pages-help
Can Pages do rewrites (not redirects)
Hi @Skye .
No, it was using
/ws/:wsid/:wsview.html /ws/:wsview 200
that caused the 308 redirect.
But when I edited and redeployed with /ws/:wsid/:wsview /ws/:wsview 200
the requests to were still going wrong - my hypothesis is my browser (Firefox) 'remembered' the 308 and keep following that.
Disabling cache in the network pane of the developer tools and requesting again was the resolution.
I'm just sharing this detail in case any other public reader is trying something similar and is being fooled by the after-effects of a redirect even after they deploy.33 replies
CDCloudflare Developers
•Created by Akira Kurogane on 4/4/2025 in #pages-help
Can Pages do rewrites (not redirects)
Something else to keep in mind if you create a Docs ticket.
33 replies
CDCloudflare Developers
•Created by Akira Kurogane on 4/4/2025 in #pages-help
Can Pages do rewrites (not redirects)
Ah, an extra gotcha - after having the 308 I think it persisted, as you would expect given it is the "Permanent Redirect" one. So deploying the right redirect rule was at first going to the incorrect URL. I had to disable cache for a bit to get past it.
33 replies
CDCloudflare Developers
•Created by Akira Kurogane on 4/4/2025 in #pages-help
Can Pages do rewrites (not redirects)
I was doing this in Firefox, in case it doesn't open in Chrome ... I've never tried the cross compatibility of those now I think about it.
33 replies
CDCloudflare Developers
•Created by Akira Kurogane on 4/4/2025 in #pages-help
Can Pages do rewrites (not redirects)
33 replies
CDCloudflare Developers
•Created by Akira Kurogane on 4/4/2025 in #pages-help
Can Pages do rewrites (not redirects)
33 replies
CDCloudflare Developers
•Created by Akira Kurogane on 4/4/2025 in #pages-help
Can Pages do rewrites (not redirects)
33 replies
CDCloudflare Developers
•Created by Akira Kurogane on 4/4/2025 in #pages-help
Can Pages do rewrites (not redirects)
They're small.
33 replies
CDCloudflare Developers
•Created by Akira Kurogane on 4/4/2025 in #pages-help
Can Pages do rewrites (not redirects)
I took one at each of three cases - using the functions middleware, trying your suggested syntax without the actual file suffix, and then again with what I did yesterday.
33 replies
CDCloudflare Developers
•Created by Akira Kurogane on 4/4/2025 in #pages-help
Can Pages do rewrites (not redirects)
Would you like the HAR files for reference?
33 replies
CDCloudflare Developers
•Created by Akira Kurogane on 4/4/2025 in #pages-help
Can Pages do rewrites (not redirects)
With the .html suffix the request to files became a 308.
33 replies
CDCloudflare Developers
•Created by Akira Kurogane on 4/4/2025 in #pages-help
Can Pages do rewrites (not redirects)
You were right @Skye
I really didn't want to go back into it, but I am nothing if not methodical.
33 replies
CDCloudflare Developers
•Created by Akira Kurogane on 4/4/2025 in #pages-help
Can Pages do rewrites (not redirects)
And also, I've already spent the time to get out of that testing branch and merge / pull things as they should be in the main branch again, I'm not going to spend the time reopening that testing setup again.
33 replies
CDCloudflare Developers
•Created by Akira Kurogane on 4/4/2025 in #pages-help
Can Pages do rewrites (not redirects)
The *.html value is the correct path to the file asset though. And it worked at doing the redirect, the user sees the path in the URL bar become
/ws/<wsviewname>.html
when it should have stayed /ws/<wsid>/<wsviewname>
the same as was requested from the link going to it from a prior page.33 replies
CDCloudflare Developers
•Created by Akira Kurogane on 4/4/2025 in #pages-help
Can Pages do rewrites (not redirects)
https://developers.cloudflare.com/rules/transform/url-rewrite/
URL rewrite: A server-side operation that converts a source URL into a target URL. It occurs before a web server has fully processed a request. A rewrite is not visible to website visitors, since the URL displayed in the browser does not change. Configure URL Rewrite Rules to perform rewrites on the Cloudflare global network without reaching your web server.
URL redirect: A client-side operation that converts a source URL into a target URL. It occurs after the web server has loaded the initial URL. In this case, a website visitor can notice the URL changing when the redirect occurs. Refer to Redirects to learn more about configuring redirects.
33 replies
CDCloudflare Developers
•Created by Akira Kurogane on 4/4/2025 in #pages-help
Can Pages do rewrites (not redirects)
There's a lot of confusion about URL rewrites.
I think confusion is expanding as the document for DNS proxying (which is out of scope for Pages, and my deliberately simple static site) has URL rewrites:
33 replies
CDCloudflare Developers
•Created by Akira Kurogane on 4/4/2025 in #pages-help
Can Pages do rewrites (not redirects)
This failed - it became a redirect, with an not-really-being-used-as-it-is-supposed-to-be 200 HTTP response code.
And not a URL rewrite.
33 replies
CDCloudflare Developers
•Created by Akira Kurogane on 4/4/2025 in #pages-help
Can Pages do rewrites (not redirects)
I tested your suggestion Skye. I assumed you meant try a 'proxying' rule. In my case that is:
33 replies
CDCloudflare Developers
•Created by Akira Kurogane on 4/4/2025 in #pages-help
Can Pages do rewrites (not redirects)
FYI some other hosting (and dev server) where the term is called rewrite rule:
https://firebase.google.com/docs/hosting/full-config#rewrites
https://github.com/lwsjs/local-web-server/wiki/How-to-rewrite-URLs-to-local-or-remote-destinations
https://docs.digitalocean.com/products/app-platform/how-to/url-rewrites/
I think it might have become popular when SPAs became a common thing, not that I'm using an SPA.
33 replies
CDCloudflare Developers
•Created by Akira Kurogane on 4/4/2025 in #pages-help
Can Pages do rewrites (not redirects)
Is the thing I learnt to call "rewrite" rules from other hosting solutions called proxying here?
33 replies