Hi @Mary!
One of the best examples to achieve your goal is on this forum. Have a “read” on this recent thread.
Www needs to be redirected to non www
Of course in this example the redirect goes from www to non-www. If you take a few minutes, the answer you seek is fully documented there.
Hope this helps!
Rip