Some of the ways to avoid this are:
- To use a 301 redirect to the original URL
- To use a rel=canonical attribute to the original content. This tells the search engine that a specific URL represents the original webpage
- To opt for a preferred domain in the Google Search Console. This can redirect spiders to crawl web pages in different ways