Feature request: Collapse adjacent slashes in URLs

I’m using Cloudflare Pages and I think it’s very nice how URLs are normalized and redirected. For example, /contact.html is redirected to /contact and /about/index.html to /about/. Also /blog is redirected to /blog/ or vice versa, depending on whether the file path is blog/index.html or blog.html.

It would be very nice if consecutive slashes would be normalized into a single one: for example, /notes//python-tips/ would be redirected to /notes/python-tips/ and ///hello to /hello (assuming no other normalizations would apply here).

Not sure if this works in combination with Pages, but have you tried to set Nomalization on the Dashboard?

Yes, I have that option enabled but it seems to have no effect with Pages. Thanks for the suggestion anyway.

1 Like

I solved this by creating a redirect rule:

When incoming requests match…

  • Edit expression:
    (raw.http.request.uri.path contains "//")


  • Type: Dynamic
  • Expression: http.request.uri.path

In fact, it works with Pages, but it’s a rewrite, not a redirect (i.e., the URL doesn’t change in the client side).

1 Like