WordPress subdomain wp-admin redirects to main domain

we have a wordpress installation running on address www.example.com.
We wanted to have a development site for it as a subdomain, so we created a subdomain dev.example.com on cpanel.
Created a duplicate of its database and replicated the files to the directory root of dev.example.com.
Then modified wp-config.php to point to the duplicate db.
Now the problem is, when we try to access dev.example.com/wp-admin, it redirects to https://www.example.com/wp-login.php?redirect_to=https%3A%2F%2Fdev.example.com%2Fwp-admin%2F&reauth=1

Anybody can help me with this?

Solutions Collecting From Web of "WordPress subdomain wp-admin redirects to main domain"