Search engines recorded referrals from links like this:
http://subdomain2.example.com. Subdomain pages display the contents of main domain pages but subdomains do not exist. CMS writes canonical link with subdomain address for subdomain page and with domain address for main domain page.
Is the correct solution for SEO to set 301 redirect from non-existent subdomains on main domain or can I just rewrite
href attribute in canonical link before output for subdomain pages?