Apa urutan arahan lokasi?
Apa urutan arahan lokasi?
Jawaban:
Dari dokumentasi modul inti HTTP :
Contoh dari dokumentasi:
location = / {
# matches the query / only.
[ configuration A ]
}
location / {
# matches any query, since all queries begin with /, but regular
# expressions and any longer conventional blocks will be
# matched first.
[ configuration B ]
}
location /documents/ {
# matches any query beginning with /documents/ and continues searching,
# so regular expressions will be checked. This will be matched only if
# regular expressions don't find a match.
[ configuration C ]
}
location ^~ /images/ {
# matches any query beginning with /images/ and halts searching,
# so regular expressions will not be checked.
[ configuration D ]
}
location ~* \.(gif|jpg|jpeg)$ {
# matches any request ending in gif, jpg, or jpeg. However, all
# requests to the /images/ directory will be handled by
# Configuration D.
[ configuration E ]
}
Jika masih membingungkan, inilah penjelasan yang lebih panjang .
/
dan /documents/
aturan cocok dengan permintaan /documents/index.html
, tetapi aturan yang terakhir diutamakan karena itu aturan terpanjang.
Itu menyala dalam urutan ini.
=
(persis)
location = /path
^~
(pertandingan maju)
location ^~ /path
~
(peka huruf besar reguler)
location ~ /path/
~*
(kasus ekspresi reguler tidak sensitif)
location ~* .(jpg|png|bmp)
/
location /path
Ada alat pengujian online yang berguna untuk prioritas lokasi sekarang:
pengujian prioritas lokasi online