Heim  >  Fragen und Antworten  >  Hauptteil

Wie Nginx statische Ressourcen abgleicht

Solange die URL ein .jgp-Suffix enthält, egal wie der Pfad lautet, /a/1.jpg oder a/f/1.jpg oder a/f/d/1.jpg, egal wie der Der Pfad wird geschrieben, solange das Suffix .jpg ist. Wie schreibe ich den Standort so, dass er mit dem Standort übereinstimmt?

漂亮男人漂亮男人2701 Tage vor863

Antworte allen(2)Ich werde antworten

  • 怪我咯

    怪我咯2017-05-27 17:47:04

    匹配后缀是.jpg

    location ~ \.jpg$ {
        ...
    }

    匹配后缀是.jpg,.gif,.png

    location ~ \.(jpg|gif|png)$ {
        ...
    }

    Antwort
    0
  • 天蓬老师

    天蓬老师2017-05-27 17:47:04

    关于配置静态目录:

    location ~* ^.+\.(ico|gif|jpg|jpeg|png|html|htm)$ {
        root         /data;
        access_log   off;
    }

    把静态资源或目录放在/data目录下,例如有:/data/img/01.jpg; 那么访问地址为:http://localhost/img/01.jpg

    注意/data目录下的文件权限哟!

    Antwort
    0
  • StornierenAntwort