Best way to track different domain requests to a canonical domain?

Longtime (years) piwik/Matomo user here, but I haven’t done anything like this.

I’ve read the FAQ and searched for this, but it’s difficult to know what to search for.

I would like to track the original accesses to several different domains that all get rewritten via 301 redirects in apache .htaccess to the canonical domain. e.g. www.dom, dom.cctld, as well as the http and https variants of each. I cannot think of how to do this, as no page with the tracking code is ever invoked except the final canonical page.

Any suggestions including even general approaches are appreciated. I’m not even sure it is possible in Matomo, or desirable to look at the stats using it.

i am also facing the same issue with my site, can you please tell what is happening here. Why this error generates. please tell!