我有一个使用nginx作为服务器的静态网站,当我想实现多语言时会遇到一些问题。
我想要的最终输出是:
mywebsite.dev -> get en-US/index.html
mywebsite.dev/about -> get en-US/about.html
mywebsite.dev/en-US/index.html -> get en-US/index.html
mywebsite.dev/en-US/about.html -> get en-US/about.html
mywebsite.dev/js-JP/index.html -> get js-JP/index.html
相反,我得到了(这很明显,但我没有任何线索可以解决这个问题)
mywebsite.dev -> get en-US/index.html
mywebsite.dev/about -> get 404 not found
mywebsite.dev/en-US/index.html -> get en-US/index.html
mywebsite.dev/en-US/about.html -> get en-US/about.html
mywebsite.dev/js-JP/index.html -> get js-JP/index.html
文件夹树:
output folder
├── img/
├── js/
├── css/
├── en-US
│ ├── about.html
│ └── index.html
└── js-JP
├── about.html
└── index.html
nginx config:
server {
listen 80;
server_name mywebsite.dev www.mywebsite.dev;
access_log /tmp/mywebsite.access.log;
error_log /tmp/mywebsite.error.log;
root /Users/path/to/output/folder;
index en-US/index.html;
}
是否可以只修改nginx配置来执行此操作?