I’m not sure if it works first time, but lets try.
server {
server_name mydomain.com www.mydomain.com;
root /var/www/html/wordpress/mydomain.com/wordpress/;
# The "^~" modifier makes this location to take priority over regex-matched locations
location ^~ /oldsite {
proxy_pass http://my.old.ip;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
index index.php index.html;
location /wp-content {
root /var/www/html/wordpress/mydomain.com/;
}
location ~ \.php$ {
# This rule now goes here, "last" changed to "break" to not leave this location after rewriting URI
rewrite ^(/[^/]+)?(/.*\.php) $2 break;
fastcgi_pass 127.0.0.1:9000;
#If a file isnt found, 404
try_files $uri =404;
#Include Nginxs fastcgi configuration
include /etc/nginx/fastcgi.conf;
}
location / {
# Two other rewriting rules goes inside the root location block to not interfere with "location ^~ /oldsite { ... }"
if (!-e $request_filename) {
# Don't use $uri here, see https://github.com/yandex/gixy/issues/77
rewrite /wp-admin$ $scheme://$host$request_uri/ permanent;
rewrite ^(/[^/]+)?(/wp-.*) $2 last;
}
try_files $uri $uri/ /index.php$is_args$args;
}
}
I comment the changes I’ve made to your config.