How to solve non-www and www issue in SEO with 301 redirect

pexels mikhail nilov 6963944
SEO