Home  >  Q&A  >  body text

nginx rewriting problem

Questions about NG rewriting

server {

    if (!-e $request_finame) {
        rewrite ^/(.*)  /index.php? last;
    }
    # or
    location / {
        if (!-e $request_finame) {
            rewrite ^/(.*)  /index.php? last;
        }
    }
}

Actually, I want to ask, the two rewriting rules are the same.
But it is written in location / and directly under the server. What's the difference.

If it is written outside, www.example.com/packages/xxx.apk cannot be downloaded.
If it is inside, www.example.com/packages/xxx.apk, as long as the path exists, it can be downloaded.

I didn't know the reason. Please kind-hearted people can clarify this. Thanks

漂亮男人漂亮男人2712 days ago439

reply all(1)I'll reply

  • 曾经蜡笔没有小新

    曾经蜡笔没有小新2017-05-16 17:26:06


    Saw it in an article.
    Nginx Rewrite Research Notes

    reply
    0
  • Cancelreply