Domain Mapping login does not redirect properly

When I try to log in with https://subsite.com/wp-login.php, it doesn't seem to redirect properly. The URL changes to https://subsite.com/wp-login.php?redirect_to=https%3A%2F%2Fsubsite.com%2Fwp-admin%2Findex.php&reauth=1.

However, if I log in from mainsite.com/subsite/wp-login.php, then it redirects properly, i.e., to mainsite.com/subsite/wp-admin/.

In the Settings page, the domain used for the administration area is set to the domain entered by the user.