How nginx matches static resources
漂亮男人
漂亮男人 2017-05-27 17:45:04
0
2
855

As long as there is a .jgp suffix in the URL, no matter what the path is, /a/1.jpg or a/f/1.jpg or a/f/d/1.jpg, no matter how the path is written, as long as the suffix is. jpg is matched by locationton, how to write this location?

漂亮男人
漂亮男人

reply all(2)
刘奇

The matching suffix is ​​.jpg

location ~ \.jpg$ {
    ...
}

The matching suffix is ​​.jpg, .gif, .png

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

About configuring static directories:

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

Place the static resources or directories in the /data directory, for example: /data/img/01.jpg; then the access address is: http://localhost/img/01.jpg

Pay attention to the file permissions in the /data directory!

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!