
Ich habe einen Wordpress-Server bei. www.mydomain.com/A/B
Die Nginx-Konfiguration ist wie folgt:
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;
}
...
}
Das funktioniert gut.
Was ich jetzt tun möchte, ist, einen alten Pfad auf den neuen Pfad umzuleiten.
Grundsätzlich möchte ich www.mydomain.com/A/B/C/XXX/YYY/ZZZ
--> www.mydomain.com/A/B/XXX/YYY/ZZZ
. Entfernen /C
.
Ich glaube, ich könnte es mit Folgendem schaffen:
location /A/B/C {
try_files $uri $uri/ /A/B/index.php?$args;
}
Aber es hat nicht funktioniert. Dann habe ich versucht
location /A/B/C {
proxy_pass http://localhost/A/B; # note the trailing slash here, it matters!
}
Ich glaube, ich brauche vielleicht einen anderen Weg, da ich den /XXX/YYY
Pfad nach dem brauche /C
.
Für jede Hilfe bin ich dankbar. Danke.
Antwort1
Sie müssen die URL neu schreiben, um das C
Pfadelement zu entfernen.
Zum Beispiel:
rewrite ^(/A/B/)C/(.*)$ $1$2 permanent;
Sie können dies im server
Block oder in einem location ^~ /A/B/C/
Block platzieren.