
특정 쿼리 매개변수가 포함된 nginx.conf의 URL을 다시 작성해야 합니다.
예로서:-
location /brands/exampleA {
if ($arg_cat = "9") {
return 301 /page/brand-filter;
}
if ($arg_cat = "38") {
return 301 /page/category/brand-filter;
}
}
이러한 URL 재작성은 example.com/brands/exampleA/?cat=9
및 example.com/page/brand-filter
에 재 example.com/brands/exampleA/?cat=38
작성 됩니다 example.com/page/category/brand-filter
.
이것들은 완벽하게 작동하지만 문제는 위치 블록의 다른 모든 하위 페이지를 깨뜨린다는 것입니다. 예를 들어 다음 페이지는 Nginx 오류로 인해 모두 로드되지 않습니다.
example.com/brands/exampleA/range1
example.com/brands/exampleA/range2
example.com/brands/exampleA/range3
example.com/brands/exampleA/range4
따라서 이후에 적용되는 모든 것을 중지하기 위해 위치 문에 추가할 수 있는 것이 있습니까 exampleA
? 이러한 재작성은 ?cat= 쿼리 매개변수와만 일치해야 합니다.
답변1
귀하의 구성은 현재 다음을 사용합니다.접두사 위치, 이는 요청된 URI가 있을 때 고려됨을 의미합니다.다음으로 시작가치 /brands/exampleA
.
일치하는 URI를 하나만으로 제한하려면 다음을 사용하세요.정확히 일치통사론:
location = /brands/exampleA/ { ... }
보다이 문서자세한 내용은.