Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

redirect-trailing-slash does nothing with active [[advanced.rewrites]] #387

Open
1 of 7 tasks
LoliPain opened this issue May 2, 2024 · 1 comment
Open
1 of 7 tasks
Assignees
Labels
bug Something isn't working help wanted Extra attention is needed v2 v2 release

Comments

@LoliPain
Copy link

LoliPain commented May 2, 2024

Search for duplicate issues

  • I already searched, and this issue is not a duplicate.

Issue scope

Docker / Kubernetes

Describe the bug

In my case I have to specify globing pattern to set alternative root path for my static. The config is:

[general]
....
redirect-trailing-slash = true
....
[[advanced.rewrites]] 
source = "/value/manage{**}" 
destination = "/$1"

That's required cause I store my static in ./public root, but endpoint is behind the nginx reverse proxy on location /value/manage

So, the accessed URL from browser is 'example.com/value/manage' provides no redirect to trailing slash URL, breaking my relative paths

I know the workaround is to specify rewrites inside reverse proxy configuration or probably just make hard redirect using [[advanced.redirects]] but anyways, the redirect-trailing-slash seems for me completely not working

How to reproduce it

  1. Create a new server with enabled {**} rewrite directive and specify redirect-trailing-slash = true
  2. Try to access server endpoint without trailing slash at the URL
    For example take example.com/manage

Expected behavior

HTTP 301 or HTTP 308 redirect to example.com/manage/ URL

Complementary information

No response

Build target

Docker linux/amd64

Environment and specs

  • static-web-server: [e.g. v1.24.1]
  • OS: [e.g. Debian 12.2, Macos 14.1.2, Windows 11, etc]
  • Arch: [e.g. x86_64 (64-bit), ARM (32-bit), ARM64 (64-bit), i686 (32-bit), etc]
  • Docker: [e.g. 20.10.7]
  • Client: [e.g. Chrome 91.0.4472.114, Firefox 119.0.1, curl, etc]
  • Specify others

Additional context

No response

@LoliPain LoliPain added bug Something isn't working v2 v2 release labels May 2, 2024
@joseluisq joseluisq added the help wanted Extra attention is needed label May 4, 2024
@joseluisq
Copy link
Collaborator

joseluisq commented May 4, 2024

Unfortunately, redirect-trailing-slash does not work when specifying URL rewrites because those are evaluated before the trailing slash check.

The way to work around this is define a URL redirect to simulate the same trailing slash redirection. So it is up to the user.

Maybe we have to think about to refine the URL rewrites functionality a bit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed v2 v2 release
Projects
None yet
Development

No branches or pull requests

2 participants