重定向那里 有部分前缀 需要跳转到主页 这样写会不会太繁琐了 这段nginx有什么优化空间吗
server {
listen 80;
server_name test-wx-h5.example.com;
root /home/admin/apps/wx-h5-dd/;
index index.html index.htm;
underscores_in_headers on;
# 重定向 精准匹配
location = / {
rewrite ^(.*)$ /ml/user/campList redirect;
}
location = /ml/ {
rewrite ^(.*)$ /ml/user/campList redirect;
}
location = /ml-class/ {
rewrite ^(.*)$ /ml/user/campList redirect;
}
location = /ml {
rewrite ^(.*)$ /ml/user/campList redirect;
}
location = /ml-class {
rewrite ^(.*)$ /ml/user/campList redirect;
}
# 子路径
location ^~ /ml {
root /home/admin/apps/wx-h5-dd/;
try_files $uri $uri/ /ml/index.html;
}
location ^~ /ml-class {
root /home/admin/apps/wx-h5-dd/;
try_files $uri $uri/ /ml-class/index.html;
}
# 接口代理
location /kb/ {
proxy_pass http://127.0.0.1:7070/;
}
access_log /alidata/log/nginx/access/example.com.log access;
}