Set domain level rel canonical with Yoast SEO [closed]

Well, the basic idea is to put this line into your header.php:

<link rel="canonical" href="http://YOUR-DOMAIN.TLD<?php echo $_SERVER["REQUEST_URI"]; ?>" />

You now have to test cases (if you want to apply the link to certain pages only).

See $_SERVER for documentation.