cloudflare / cloudflare/workers-sdk

Redirect source URLs ending in a slash should also match slashless URL

Open
#1,334 3 comments 0 reactions 3 assignees Claimed by @stritt View on GitHub
package:pages-shared package:workers-shared product:pages
Dominant language
TypeScript
Stars
4.5k
Forks
1.5k
Avg merge
3d 8h
Merged PRs (30d)
186

Description

### What version of `Wrangler` are you using?

2.0.15

### What operating system are you using?

Linux

### Describe the Bug

It is widespread standard practice to redirect "directory" URLs not ending in a slash to the equivalent (canonical) URL ending in a slash, provided the directory index exists, and Cloudflare Pages already does so.

For instance, `https://www.example.com/foo` would typically redirect to `https://www.example.com/foo/`.

As such, I strongly believe that a redirect like `/foo/ /bar/ 301`,
as well as redirecting `/foo/` to `/bar/`,
**should also redirect `/foo` to `/bar/`**.

Another argument is that, let's say you have a directory index at `/foo/` (and `/foo`), and later you decide to delete it and replace it with a redirect with source URL `/foo/`, then the `/foo` URL (redirect to canonical) will not work anymore, which doesn't seem logical. And I think `/foo` would still work if you added the redirect but (deliberately or accidentally) did not delete the file, which is a bit weird.

For now, the workaround is to manually create that second redirect every time, but this seems gratuitously painful.

(Note that a redirect of `/foo /bar/ 301` should NOT also redirect `/foo/`, because `/foo.txt /bar.txt 301` clearly should not redirect `/foo.txt/`.)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.