Zend certified PHP/Magento developer

Magento 2: how to stop only redirect url for googlebot?

I have websites in .ca and .com. If someone hit .ca website from USA ip address it automatically
redirects on .com and if it hits on .com website using CANADA ip address it automatically redirects on .ca website. The problem is google not indexing any .ca website urls. It just indexing only .com URLs.

How can I enable redirection process only for real users not for google indexing?

Should I use redirect with any certain response code?