
www.mydomain.com/A/B
Nginx 구성 에 Wordpress 서버가 있습니다 .
server {
listen 80 default;
root /var/www/html;
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location /A/B {
try_files $uri $uri/ /A/B/index.php?$args;
}
...
}
이것은 잘 작동합니다.
지금 내가 하고 싶은 일은 레거시 경로를 새 경로로 리디렉션하는 것입니다.
기본적으로 나는 www.mydomain.com/A/B/C/XXX/YYY/ZZZ
--> 를 원한다 www.mydomain.com/A/B/XXX/YYY/ZZZ
. ./C
나는 다음과 같이 할 수 있다고 믿습니다:
location /A/B/C {
try_files $uri $uri/ /A/B/index.php?$args;
}
그러나 그것은 작동하지 않았습니다. 그런 다음 시도했습니다.
location /A/B/C {
proxy_pass http://localhost/A/B; # note the trailing slash here, it matters!
}
. /XXX/YYY
이후 경로가 필요하기 때문에 다른 방법이 필요할 수도 있습니다 ./C
도움을 주시면 감사하겠습니다. 감사합니다.
답변1
경로 요소 를 제거하려면 URL을 다시 작성해야 합니다 C
.
예를 들어:
rewrite ^(/A/B/)C/(.*)$ $1$2 permanent;
이것을 블록에 배치할 수도 server
있고 location ^~ /A/B/C/
블록에 배치할 수도 있습니다.