nginx - 301 redirect wrong URLs used on extern website

Solution 1:

All URIs in Nginx begin with a leading / and are normalised to remove consecutive //s.

You should change your regular expression to: ^/https:/subdomain\.example\.com/index\.php$ and place it above the location block which matches URIs ending with .php.

Alternatively, use an = operator to exactly match a single URI, for example:

location = /https:/subdomain.example.com/index.php {
    return 301 /index.php$is_args$args;
}

See this document for details.