Nginx: Rewrite rule for subfolder

Solution 1:

You must not escape the period (.) in the second part of the rewrite:

rewrite ^/example3\.com/(.*)$ /example3\.com/index.php?id=$1 last;

should be

rewrite ^/example3\.com/(.*)$ /example3.com/index.php?id=$1 last;

But what does your id look like? If it's a number, you could try this out:

location /example3.com/ {
    index  index.php;
    rewrite "^/example3\.com/([0-9]+)$" /example3.com/index.php?id=$1 break;
}