Nginx如何将regex中的多个位置映射到单个目录
我的应用程序使用单个web应用程序(HTML和Javascript)为多个(动态金额)系统提供服务 系统通过类似URL的Nginx如何将regex中的多个位置映射到单个目录,nginx,Nginx,我的应用程序使用单个web应用程序(HTML和Javascript)为多个(动态金额)系统提供服务 系统通过类似URL的http://localhost/sites/,其中系统id仅允许小写字母 假设web应用程序位于/opt/myapp中。如何在nginx中配置它 我试过以下方法,但都不管用 location ~ /sites/[a-z]+ { alias /opt/myapp; index index.html index.htm; } 输入http://localhost/
http://localhost/sites/
,其中系统id
仅允许小写字母
假设web应用程序位于/opt/myapp
中。如何在nginx中配置它
我试过以下方法,但都不管用
location ~ /sites/[a-z]+ {
alias /opt/myapp;
index index.html index.htm;
}
输入http://localhost/sites/abc/
,已禁用403
输入http://localhost/sites/abc/index.html
,仍然403禁止
并且URL自动更改为http://localhost/sites/abc/index.html/
对于location~/sites/[a-z]+/{}
我试过了
location ~ /sites/[a-z]+ {
alias /opt/myapp/;
index index.html index.htm;
}
输入
http://localhost/sites/abc
,URL重定向到http://localhost/sites/abc/index.html/index.html/index.html/index.html/index.html/index.html/index.html/index.html/index.html/index.html/index.html/index.html/index.html/index.html/index.html/index.html/index.html/index.html/index.html/
正则表达式中的别名
指令位置
必须构成文件的完整路径
例如:
location ~ ^/sites/[a-z]+(/.*)?$ {
alias /opt/myapp$1;
index index.html index.htm;
}
有关详细信息,请参阅