need.htaccess 301 redirect code for any pages starting with //www.example.com to home page of //example.com
I would like to add an one catches all .htaccess 301 redirect code for any (old)url starting with https://www.example.com to the home page of https://example.com. (without www.) The permalinks are not the same, that’s why all pages should go to the same page https://example.com/home.
I used to have a html site created with dreamweaver, starting with https://www.example.com Now my new wordpress site is without www. When searching with google, site:www.example.com there are 70 old pages of my website still starting with www. I have them redirected individually in WP htaccess, but that makes my website slow loading. There must be a smarter way to do that… Can anyone explain how, what and where to add better code?