vitepress
vitepress copied to clipboard
add nginx config example
Is your feature request related to a problem? Please describe.
Hard to understand how netllify example should be rewritten for nginx
/* /es/:splat 302 Language=es
/* /fr/:splat 302 Language=fr
/* /en/:splat 302
Describe the solution you'd like
nginx config wll be nice to present in doc
Describe alternatives you've considered
No response
Additional context
No response
Validations
- [X] Follow our Code of Conduct
- [X] Read the docs.
- [X] Read the Contributing Guidelines.
- [X] Check that there isn't already an issue that asks for the same feature to avoid creating a duplicate.
Try the solutions mentioned in this threads - https://stackoverflow.com/a/9983986/11613622 -- you can also search online for similar solutions (make a web search on something like "nginx redirect based on language header"). Please let us know whichever solution works for you. We will add that to docs.
О... that's my misunderstanding. I thought that vitepress would add the language prefix to all urls in the sidebar automatically, and that this required setting a parameter in the cookie that would redirect the server to the correct language prefix.
There is no information in the documentation that you need to add the language prefix yourself. After that I didn't need any redirect. A redirect is needed to redirect to the desired language from the browser language. Of course, there are plenty of examples for this in your links.
cleanUrls: true
with nginx conf
root /viteproject/.vitepress/dist;
location / {
try_files $uri $uri/ $uri.html =404;
}
I used this nginx settings. it is worked
I use the following code snippet, and it works well:
map $http_accept_language $lang {
default "";
~*^zh zh;
}
server {
...
location = / {
rewrite (.*) $1/$lang;
root html/my-docs;
index index.html;
}
location / {
root html/my-docs;
index index.html;
}
}