Home  >  Q&A  >  body text

Problems with nginx handling static resources

I have such a request URL http://example.com/virtualpat..., all requests start from virtualpath, the actual directory corresponding to avatar.png is /home/www/static /avatar.jpg, how to let nginx process this static file directly? When I set root /home/www, the final directory nginx accesses is /home/www/virtualpath/static/avatar .jpg, then it will be 404. How to configure nginx for such a problem?

给我你的怀抱给我你的怀抱2704 days ago672

reply all(1)I'll reply

  • 仅有的幸福

    仅有的幸福2017-05-24 11:34:50

        location ~ .*virtualpath(.*)\.(jpg|png|gif){
            root "/home/www";#指定图片存放路径
            try_files $uri . last;
        }

    reply
    0
  • Cancelreply