Redirects not working for URLs with dots "."
Have you read the Contributing Guidelines on issues?
- [X] I have read the Contributing Guidelines on issues.
Prerequisites
- [X] I'm using the latest version of Docusaurus.
- [ ] I have tried the
npm run clearoryarn clearcommand. - [ ] I have tried
rm -rf node_modules yarn.lock package-lock.jsonand re-installing packages. - [ ] I have tried creating a repro with https://new.docusaurus.io.
- [ ] I have read the console error message carefully (if applicable).
Description
I am using the plugin-client-redirects to redirect URLs, but it appears that redirects do not work for URLs containing periods (dots). Is this intended behavior, or is there a workaround to make such redirects work properly? (use createRedirects instead?)
redirects: [
{
from: [
"/test", // This works
"/te.st", // Does not work
],
to: "/another",
},
],
Reproducible demo
No response
Steps to reproduce
- yarn add @docusaurus/plugin-client-redirects
- adds code to
docusaurus.config.js
Expected behavior
When I enter 'mysite.com/te.st,' it should redirect me to 'mysite.com/another,' but it doesn't work.
Actual behavior
the expected redirection is not occurring as intended
Your environment
- Public source code:
- Public site URL:
- Docusaurus version used:
- Environment name and version (e.g. Chrome 89, Node.js 16.4):
- Operating system and version (e.g. Ubuntu 20.04.2 LTS):
Self-service
- [ ] I'd be willing to fix this bug myself.
Hi, are you using yarn serve or some third-party server. FYI, it works if you rename build/te.st/index.html to build/te.st.html for me when using yarn serve. The reason is because our serve handler thinks .st is already an extension, so it doesn't even try to lookup for te.st/index.html. Theoretically, you should be able to make it emit te.st.html in the first place with trailingSlash: false, but our redirects plugin does not honor that.
@slorber, do you think it should output te.st.html to make this case work? There are a lot possible redirect loops to be aware of, though!
Considering the redirect file te.st/index.html is emitted, it looks like an issue with the way the static deployment is served, and it's likely that different hosts lead to different behaviors.
I don't know what to do exactly but we'd rather just say that the client redirect plugin is a best effort and can't work for all use-cases. It's not really worth investing a ton of time finding the impossible common denominator that works for all cases and hosts when client redirects are antipatterns in the first place 😅