配置Nginx以忽略url中的路径

时间:2016-07-02 07:31:12

标签: nginx url-rewriting nginx-location auto-versioning ngx-http-rewrite-module

我的网站位于/root/website/,其中有一个文件夹static用于静态文件,当用户访问:/static/dfd99a5/xxx.js时,我希望提供/root/website/static/xxx.js,如何我可以在nginx中这样做吗?

1 个答案:

答案 0 :(得分:1)

您可以使用rewrite指令,如下所示:

location ~ ^(/static)/[0-9a-f]+(/.+)$ {
    rewrite ^ $1$2 break;
}