1、hash模式时(#),nginx配置方法
location ~ ^/test/cms-h5/{
rewrite ^/test/cms-h5(.*)$ $1break;
root/opt/nginx/web/cms-h5/dist;
}
2、hisotry模式时,nginx配置方法
location ~ ^/test/cms-h5/{
try_files $uri@cms-h5;
}
location@cms-h5{
rewrite ^/test/cms-h5(.*)$ $1break;
try_files $uri /test/cms-h5/$uri//test/cms-h5/index.html;
root/opt/nginx/web/plus/cms-h5/dist;
}
或者
location ~ ^/test/cms-h5/{
rewrite ^/test/cms-h5(.*)$ $1break;
try_files $uri /test/cms-h5/$uri//test/cms-h5/index.html;
root/opt/nginx/web/plus/cms-h5/dist;
}
3、备注
# 对于对象存储类的域名配置,建议增加请求头
通用配置(后端由nginx代理到minio)
rewrite ^/(.*).(svg|tif|tiff|wbmp|png|bmp|fax|gif|ico|jfif|jpe|jpeg|jpg|woff|cur|webp|swf|ttf|eot|woff2|css|js|txt|json|xhtml|html|map|rplib)$ /frontend/game/page/$1.$2 last;
rewrite ^/(.*)/? /frontend/game/page/index.html last;
location / {
if ($request_method = POST){
return 403;
}
if ($request_method = PUT){
return 403;
}
if ($request_method = DELETE){
return 403;
}
proxy_set_header Host minio.herlly.cn;
proxy_pass http://minio-nginx;
}
标签:vue,nginx,模版,rewrite,h5,Nginx,location,test,cms
From: https://blog.51cto.com/zzzhao/6223763