죄송합니다.이 질문을 여러 번 물어보십시오. 내가 nginx 적절한 재작 성을 할 수 없습니다. URL의 마지막 부분을 제거해야합니다. 예를 들어,이되는 URL 내가 가진 :nginx url을 다시 쓰고 마지막 부분을 제거하십시오
https:/mydomain.com/this/is/some/url/page/0
https:/mydomain.com/this/is/some/url/page/1
내가이 이들 모두를 다시 작성해야합니다
https:/mydomain.com/this/is/some/url
이것은 내가 지금까지 시도한 것입니다 :
location/{
...
rewrite ^/(.*)/page/0|1$ $1 last;
...
}
그러나 작동하지 않습니다. 그것이 나에게 맞는 것 같습니다. 그게 뭐가 잘못 됐니? (나는 정규식이 싫다.)
편집 :
location/{
# Remove trailing double slashes.
if ($request_uri ~ "^[^?]*?//") {
rewrite "^" $scheme://$host$uri permanent;
}
# Remove trailing slashes.
rewrite ^/(.*)/$ /$1 permanent;
# Rewrite page/0 and page/1 from url.
rewrite ^/(.*)/page/[01]$ /$1 last;
proxy_pass http://backend_web;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
'rewrite ... last'는 프록시를 통해 전달 된 URI를'backend_web'으로 변경합니다. 브라우저 주소 표시 줄에 URI를 변경하려면 'rewrite ... redirect'를 사용해야합니다. –