首页 > 解决方案 > Rewrite except loading JS files

问题描述

In my nginx setting, I have the following rewritting

location ~* ^/1/\b(?!#|auth)\w+\b/? {
    rewrite ^/1/(.*)$ https://www.funfun.io/1/#/$1 redirect;
}

As a result, www.funfun.io/1/home will be rewritten to www.funfun.io/1/#/home, which is what I want.

However, www.funfun.io/1/3.bundle.js will be written to www.funfun.io/1/#/3.bundle.js too, which is NOT what I want. I want to leave www.funfun.io/1/3.bundle.js, more generally www.funfun.io/1/*.js, as it is.

Does anyone know how to specify that in the nginx block?

标签: regexnginxurl-rewritingurl-redirection

解决方案


您可以在重写中排除序列。

像这样的东西应该工作:

rewrite ^/1/(.*[^.][^j][^s])$ https://www.funfun.io/1/#/$1 redirect;

推荐阅读