我在定义 nginx 规则时遇到了一些问题
当我访问 localhost:3000 时,我需要获取 index.html 但是,当我得到 localhost:3000/dummy/folder/assetA.js 我希望它也能工作。 根据我的设置,第二部分不起作用。 我的正则表达式有问题还是重写不是最好的选择?
- var/www
- innerFolderA
- innerFolderB
- index.html
- assetA.js
- assetB.js
http {
server {
# listen on port 3000
listen 3000;
# save logs here
access_log /var/log/nginx/access.log compression;
# where the root here
root /var/www;
# what file to server as index
index index.html index.htm;
location / {
try_files $uri $uri/ /index.html;
}
location /dummy/folder {
rewrite ^(\/dummy\/folder\/)(.*)$ \/$2 break;
}
}
}